Conversation
|
From today:
|
|
|
||
| const {sharedVars} = getCollections(); | ||
| const username = this.caller.username; | ||
| const variable = await sharedVars.findOne({name: name}); |
There was a problem hiding this comment.
Calling findOne then updateOne can be prone to concurrency bugs. I would use $push instead: https://www.mongodb.com/docs/manual/reference/operator/update/push/. (Then return an error if it fails.)
There was a problem hiding this comment.
Thanks, I forgot they would be stored as actual lists in the DB
…vices into 1-read-only-cloud-variables
|
@brollb Something we didn't discuss that I just caught, should the _sendUpdate call when appending send the entire new list, or just the new value? Both seem like valid possibilities, but sending just the value appended is definitely simpler (and avoids bringing the concurrency issue back). |
|
I would probably send the update with the entire list since there isn't currently a distinction between |
|
Thanks, that will work. |
Close #1
Adds a
setVariableAccessmethod where access levels can be set for other users with/without password. Old variables and variables created by logged-out users will default to all users with password having full access and without password having no access (except for unlocking a lock your client owns, although it shouldn't come up).Remaining questions: