-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make GlobalConfig work like parse.com #1210
Conversation
Current coverage is
|
.then(() => ({ response: { result: true } })); | ||
.then(coll => coll.find({ '_id': 1 }, { limit: 1 })) | ||
.then(results => { | ||
const previousConfig = results && results[0] && results[0].params || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should do it in one op, and use $unset when op delete is set
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flovilmart:
The main problem is that I can't merge nested documents with $set afaik.
The whole params
object get replaced with the new one.
{"params": {"a":"b"}}
In mongodb:
{"params": {"a":"a", "b":"b"}}
Result:
{"params": {"a":"b"}}
Expected:
{"params": {"a":"b", "b": "b"}}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shoot... It's been poorly designed... Can you try with dot notation? I believe that works also $unset supports dot notation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. Dot notation works and some params manipulation works, awesome!
@framp updated the pull request. |
@@ -18,20 +18,20 @@ export class GlobalConfigRouter extends PromiseRouter { | |||
} | |||
|
|||
updateGlobalConfig(req) { | |||
const params = req.body.params; | |||
const update = {}; | |||
Object.keys(params).forEach((key) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use reduce instead of out of block scope assignment? Initial value with {$set:{}, $unset:{}}?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, but mongo is complaining if $set or $unset are empty objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, so empty initial. I prefer avoiding assigning on out of blocks objects
@framp updated the pull request. |
Sorry for the pickiness :) but that's great ! Thanks!!!! |
Glad to help and thanks for the review! |
As per title:
PARSE_EXPERIMENTAL_CONFIG_ENABLED
orTESTING
the server features route will return config, making it work properly withparse-dashboard
A lot of tests are failing with
npm test
, not sure if it's an issue with my setup (Arch Linux, already have mongodb but it's not running) or with the project. For the time being I'll rely on whatever circleci you guys are using.npm test spec/ParseGlobalConfig.spec.js
seems fine.