Created
February 17, 2020 15:34
-
-
Save hexsprite/ce978af77b78adc3ead6c3ba1227c15c to your computer and use it in GitHub Desktop.
MeteorJS: apply a mongo update to an object "in-memory"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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