Meteor update a Collection object -


in meteor, i'm having collection schema, , number of items added dynamically.

in case, i'm dealing milestones object, , once user check 1 off want update complete in collections item true (default false)

here schema

milestones: { type: array, optional: true }, 'milestones.$': { type: object }, 'milestones.$.name': { type: string }, 'milestones.$.hours': { type: number }, 'milestones.$.complete': { type: boolean } 

how write $set statement this?

you have array of objects so, $elemmatch trick here.

projects.update({_id:this._id},{milestones:{$elemmatch:{'milestones.$‌​.name':this.name}},{$set:{'milestone.$.complete':value}}}) 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -