question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Array must contain values for all object properties

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
alaziercommented, Feb 27, 2016

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 #242

Until we support this you could insert using a loop or one of the array iteration methods:

realm.write(() => {
   response.mmArray.forEach((values) => {
      realm.create('MM', values, true);
   });
});
0reactions
melihmucukcommented, Mar 1, 2016

Yes, Chrome debug mode was the issue. After disabling chrome debug mode, 20k items take ~2 seconds. Thanks !

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found