-
-
Notifications
You must be signed in to change notification settings - Fork 364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Maps Nested unknown attributes not set when saveUnknown is true #323
Comments
@fishcharlie I wish to contribute, to fix this bug and nested partial updates bug, both are troubling me too much. I wish to fix them but I fail to understand the flow of execution of code. Is there any way that you or somebody can put a walk through of the basic code in plain english, so that it is easy to follow code. Thanks |
@jignesh248 Awesome!! Honestly I haven't looked through this section of the code very much. Do you have any specific questions or are you looking for a broad overview? |
just looking for a broad overview.
I dunno in other thread you have created a PR for saveUknown failing silently even on top level, I guess that part is working on version released on NPM but only nested unknown field fails . |
@jignesh248 Yeah I jut moved that to a separate issue (this one). I would look into that PR that was created for the top level stuff and see if you can replicate it for nested items. Sadly that's the only insight I have right now. |
This is still an issue. I don't think that PR resolved it. const dynamoose = require('dynamoose');
const shortId = require('shortid');
const Schema = dynamoose.Schema;
const schema = new Schema({
adUrlId: {
type: String,
rangeKey: true,
default: shortId.generate
},
customerId:{
type: String,
required: true,
hashKey: true
},
userId: {
type: String,
required: true
},
title : {
type: String,
required: true
},
type: {
type: String,
required: true
},
desktop: Map
mobile: Map,
app: Map,
campaignId: {
type: String,
required: true,
index: {
global: true,
rangeKey: 'customerId'
}
}
});
const Model = dynamoose.model('AdUrl', schema,{
update: true,
timestamps: true,
useDocumentTypes: true,
saveUnknown: ['mobile'],
throughput: {
read: 1,
write: 1
}
});
module.exports = Model; Saving New model with a nested mobile property "123". try {
const AdUrlModel = req.app.locals.MODELS.AdUrl;
const adUrlModel = new AdUrlModel({
title: '123',
type: 'cats',
userId: 123,
customerId: 123,
campaignId: 123,
mobile: {
"123" : '123'
}
});
const results= await adUrlModel.save();
res.json(results);
}catch(e){
} Outcome {
"title": "123",
"type": "cats",
"userId": "123",
"customerId": "123",
"campaignId": "123",
"mobile": {},
"adUrlId": "r3szmtJs9"
} Mobile property did not save..... |
@dobrynin Thoughts on this? |
I think the problem may be that the changes I applied were only to |
@dobrynin Any chance you could create a PR for that and add a test for this? |
Curious: has there been any movement on this issue? My team is running across this problem as well, with a case similar to what mbejda described. |
@bwaters57, sorry haven’t had the chance to look into this yet. Hopefully this weekend. If you have a solution and would like to submit a PR, you’re welcome to do that :) |
I tried to take a look at this. I'm struggling to create a failing test case tho. I'm having the same problem in one of my projects. Not sure why I'm not able to create a failing test case. Or solve it. |
If it helps make a failing case for testing, here is the generalized schema that we're working with:
And an example of this would be:
For context, the reason the Map is generic is because the keys within are a composite of code1 and code2 that we will later be filtering on. Similar to mbejda's post above, saving and retrieving my example yields the following:
|
@bwaters57 I think I figured this out. Working on creating a PR now. |
this fixes how schema options can be defined and updated fix dynamoose#323
this fixes how schema options can be defined and updated fix dynamoose#323
this fixes how schema options can be defined and updated fix dynamoose#323
## [1.6.2](v1.6.1...v1.6.2) (2019-02-13) ### Bug Fixes * **saveunknown:** fixing saveunknown toDynamo for maps ([873a6ed](873a6ed)), closes [#323](#323)
@mbejda One thing I just connected the dots on. Is the |
Maps Nested unknown attributes not set when saveUnknown is true. This issue is related to #236.
The text was updated successfully, but these errors were encountered: