Error when I save a particular format of data[mongo db]

Plugin Development
  • I try to save this code data:

    [{"uid":"1","name":["Andreas"]}]

    where uid is a field and name is a array. But when I do db.setObject I obtain this error:

    Modifiers operate on fields but we found a Array instead. For example: {$mod: {<field>: ...}} not

    Anyone can help me to save in my format?

  • you need to wrap it like {"value": [{"uid":1,"name":["Andreas"]}]}. Arrays are no (direct) instances of Objects; Thus not allowed to be used within db.setObject.

    EDIT: Actually [] instanceof Object === true. It's just not allowed by the database clients since Arrays are no conventional key/value stores.


Suggested Topics