Just curious which of the following is more efficient if I want to "reset" a (single) document to its initial state if it exists, or create a new one if it doesn't.
Collection.remove({ initialField: "dirtyString" });
Collection.insert({ initialField: "initialString" });
or
let _id = Collection.findOne({ initialField: "dirtyString" });
Collection.update(_id, { initialField: "initialString" });
Thanks!
用单个命令执行所有操作有什么问题?
Collection.update({ initialField: "dirtyString" }, { initialField: "initialString"});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.