-
Notifications
You must be signed in to change notification settings - Fork 7
Support $select in get and make sure patch many only returns changed items #32
Conversation
@@ -20,7 +20,8 @@ function common (app, errors, serviceName = 'people', idProp = 'id') { | |||
); | |||
|
|||
it('sets `events` property from options', () => | |||
expect(app.service(serviceName).events).to.deep.equal([ 'testing' ]) | |||
expect(app.service(serviceName).events.indexOf('testing')) | |||
.to.not.equal(-1) |
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.
It's checking for Array index in case we already have existing events (the case e.g. in RethinkDB)
@@ -522,20 +535,23 @@ function common (app, errors, serviceName = 'people', idProp = 'id') { | |||
}).then(() => service.remove(null, params)); | |||
}); | |||
|
|||
it('patches multiple even if query changed', () => { | |||
it('patches multiple, returns correct items', () => { | |||
const service = app.service(serviceName); |
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.
The current (buggy) implementations make just another find
with the changed query which is not correct. What they really need to do is find
everything before making the database update and then do another find with the list of all ids from the previous find. This tests covers that.
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.
Looks good!
Technically $select should be possible on those methods. I think they are unlikely cases except for update but if we're already here it would make sense to add the tests for them. |
If you want to include that in this PR go for it. Otherwise |
I added tests for all other methods now as well. |
Related to feathersjs/feathers#450 and feathersjs-ecosystem/feathers-mongoose#124 (comment)
Closes #25
@feathersjs/core-team Should $select be tested and supported for
patch
,update
,remove
andcreate
as well?