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


  • Error when importing library

    Unsolved Plugin Development
    0 Votes
    7 Posts
    113 Views
  • 0 Votes
    12 Posts
    285 Views
  • 0 Votes
    5 Posts
    2163 Views
  • 0 Votes
    1 Posts
    1003 Views
  • two plugin error

    Plugin Development
    0 Votes
    7 Posts
    1778 Views