Skip to content

Instantly share code, notes, and snippets.

@hexsprite
Created February 17, 2020 15:34
Show Gist options
  • Save hexsprite/ce978af77b78adc3ead6c3ba1227c15c to your computer and use it in GitHub Desktop.
Save hexsprite/ce978af77b78adc3ead6c3ba1227c15c to your computer and use it in GitHub Desktop.
MeteorJS: apply a mongo update to an object "in-memory"
/** Given an object, apply a Mongo update and return the resulting document */
function mongoUpdate(obj: Action, update: any): Action {
const collection = new Mongo.Collection<Action>(null)
const objId = collection.insert(obj)
collection.update(objId, update)
return collection.findOne(objId)!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment