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
2
  • Try adding blackbox: true to the "drags.$.$.fixed" field in the schema? Commented Oct 15, 2015 at 14:57
  • that does not help and how should it? "drags.$.$.fixed" is boolean, so that would not be a problem. Commented Oct 15, 2015 at 15:24

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.