Error: Array must contain values for all object properties
See original GitHub issueI have schema like below:
const MMSchema = {
name: 'MM',
primaryKey: 'art',
properties: {
art: 'int',
tar: {type: 'string', optional: true},
p_date: {type: 'string', optional: true},
p_time: {type: 'string', optional: true},
article: {type: 'string', optional: true},
design_no: {type: 'string', optional: true},
grp: {type: 'string', optional: true},
color: {type: 'string', optional: true},
composition: {type: 'string', optional: true},
width: {type: 'int', optional: true},
weight: {type: 'int', optional: true},
barcode: {type: 'string', optional: true},
drm: {type: 'string', optional: true},
d_date: {type: 'string', optional: true},
adet: {type: 'int', optional: true},
c_adet: {type: 'int', optional: true},
ey: {type: 'int', optional: true},
gy: {type: 'int', optional: true},
ys: {type: 'int', optional: true},
}
};
sample input:
{"mmArray": [
{
"art": 2,
"tar": "2011-01-21T00:00:00Z",
"p_date": "2016-01-19T00:00:00Z",
"p_time": "16:51:21",
"article": "HI-MULTI CHIFFON",
"design_no": "",
"grp": "",
"color": "",
"composition": "100%PES",
"width": 150,
"weight": 55,
"barcode": "K00000002",
"drm": "A",
"d_date": "2011-01-21T00:00:00Z",
"adet": 1,
"c_adet": 0,
"ey": 3,
"gy": 5,
"ys": 8
},
{
"art": 4,
"tar": "2011-01-21T00:00:00Z",
"p_date": "2015-04-04T00:00:00Z",
"p_time": "11:31:59",
"article": "SPUN VISCOSE",
"design_no": "",
"grp": "",
"color": "",
"composition": "100%VI",
"width": 150,
"weight": 125,
"barcode": "K00000004",
"drm": "A",
"d_date": "2011-01-21T00:00:00Z",
"adet": 1,
"c_adet": 0,
"ey": 3,
"gy": 5,
"ys": 8
}
]}
It works:
realm.write(() => {
realm.create('MM', response.mmArray[0], true);
});
It doesn’t work.
error message: Array must contain values for all object properties
realm.write(() => {
realm.create('MM', response.mmArray, true);
});;
How can I write batch ?
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to add a nested List of objects in Realm "Error: JS value ...
I'm trying to create Realm database that has a json array of objects with a nested array of objects.
Read more >Realm schema for different object types in array - MongoDB
I am trying to configure a Realm schema and Realm GraphQL (and later Sync) to support data where an array of objects can...
Read more >Schema validation reference for object types
The schema defines an array and any of the items in the array are of type object . The only array item types...
Read more >Additional Items - Liquid Technologies
The value of "additionalItems" MUST be either a boolean or an object. ... If it is an array, items of this array MUST...
Read more >Object.values() - JavaScript - MDN Web Docs
Non-object arguments are coerced to objects. Only strings may have own enumerable properties, while all other primitives return an empty array.
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
Just to be clear, your first example with
response.mmArray[0]
works alright but batch insertion does not? If so that is because we don’t yet support batch insertion. There is an issue for this here #242Until we support this you could insert using a loop or one of the array iteration methods:
Yes, Chrome debug mode was the issue. After disabling chrome debug mode, 20k items take ~2 seconds. Thanks !