[BUG] Schema option `saveUnknown` is not working for an array
See original GitHub issueSummary:
Setting the Schema option saveUnknown
to true
works as expected, but using an array does save empty objects into DynamoDB:
const catSchema = new dynamoose.Schema({
name: String,
something: Object,
somethingElse: Object,
}, {
saveUnknown: [
'something',
'somethingElse',
],
});
const catModel = dynamoose.model('Cat', catSchema);
const cat = {
name: 'Test',
something: {
hello: 'world',
},
somethingElse: {
hello: {
world: 'hello!',
},
anArray: [1, 2, 3, 4],
}
};
await catModel.create(cat);
aws:dynamodb:putItem:request - {
"Item": {
"name": {
"S": "Test"
},
"something": {
"M": {}
},
"somethingElse": {
"M": {}
}
},
"TableName": "Cat",
"ConditionExpression": "attribute_not_exists(#__hash_key)",
"ExpressionAttributeNames": {
"#__hash_key": "name"
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Schema - Dynamoose
saveUnknown, array | boolean, false, This setting lets you specify if the schema should allow properties not defined in the schema. If you...
Read more >Enum inside the Array is not validting in json-schema
I am validating the json with json_schema. Allowed values for ghrBillingCode should be only "I9NOT". expected result should be error as 2nd and ......
Read more >dynamoose/CHANGELOG.md - UNPKG
168, This version adds some more options to the model and schema options objects. ... Please give feedback on plugins by creating issues...
Read more >array — Understanding JSON Schema 2020-12 documentation
{"Not": "an array"}. There are two ways in which arrays are generally used in JSON: List validation: a sequence of arbitrary length where...
Read more >JSON schema to PL/I mapping - IBM
Should the above behavior be undesirable the user can specify MAPPING-OVERRIDES=NO-ARRAY-NAME-INDEXING as input to the utility which disables the addition of ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So the problem was that
saveUnknown
only effects the first layer. In my case wildcards*
and**
should have been used as stated in the docs.@chadlittle Sounds good. Keep in mind, it’s also better to set the schema property as opposed to
saveUnknown
. That way it’s more clear what is actually being saved. I’d only recommend saveUnknown for cases when you truly don’t know what you are saving or what your schema looks like.