Glavin001 / Cobra

API Server for storing and graphing real-time time-series data in MongoDB
MIT License
18 stars 1 forks source link

Switch to using setOnInsert #2

Closed Glavin001 closed 9 years ago

Glavin001 commented 9 years ago

See http://docs.mongodb.org/manual/reference/operator/update/setOnInsert/#up._S_setOnInsert

Instead of trying to update and then inserting on update failure and trying to update after insert; simply use setOnInsert in the initial update! See https://github.com/Glavin001/Cobra/blob/master/server/index.js#L237-L262

Glavin001 commented 9 years ago

Performance is actually not as good:

Glavin001 commented 9 years ago

image

Glavin001 commented 9 years ago

Implemented on branch https://github.com/Glavin001/Cobra/tree/setOnInsert