0

I am using SimpleSchema with Meteor for Structuring the Database Entries.

The problem is, I have an array of arrays of objects (These data is displayed inside of an HTML table) and need to update single cells.

My Schema looks like: (Coffeescript)

drags:
    type: [[Object]]
    label: "The correct assignment of drop values"
    optional: true
    blackbox: true
"drags.$":
    type: [Object]
    label: "Row of the Table"
    blackbox: true
"drags.$.$":
    type: Object
    label: "Cell of the Table"
"drags.$.$._id":
    type: String
    label: "Unique Id of Draggable"
    optional: true
"drags.$.$.text":
    type: String
    label: "Text of Draggable"
    optional: true
"drags.$.$.fixed":
    type: Boolean
    label: "Is this Draggable Fixed to the correct spot"
    optional: true
"drags.$.$.color":
    type: String
    label: "Color of Draggable"
    optional: true

My Database call to update a specific cell is:

db.update({_id:"some-id"},{$set: {"drags.1.2.fixed":true}})

This call throws this error:

Error: When the modifier option is true, validation object must have at least one operator
Tobi
  • 1,175
  • 1
  • 19
  • 44

1 Answers1

3

It's almost always easier with simple-schema to define the schema for each tier separately and them nest them. In your case:

drags: 
  type: [row]
  label: "The correct assignment of drop values"
  optional: true
  blackbox: true

row:
  type: [cell]

Then define your cell properties. Normally if you define an object as being blackbox there's no point in defining its individual properties. You've got one required field at the cell level but above that you're saying it's blackbox.

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39