Skip to content
This repository has been archived by the owner on Dec 17, 2018. It is now read-only.

Support $select in get and make sure patch many only returns changed items #32

Merged
merged 4 commits into from
Nov 11, 2016

Conversation

daffl
Copy link
Member

@daffl daffl commented Nov 8, 2016

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 and create as well?

@@ -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)
Copy link
Member Author

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);
Copy link
Member Author

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ekryski
Copy link
Member

ekryski commented Nov 8, 2016

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.

@ekryski
Copy link
Member

ekryski commented Nov 8, 2016

If you want to include that in this PR go for it. Otherwise :shipit:

@daffl daffl changed the title Support in get and make sure patch many only returns changed items Support $select in get and make sure patch many only returns changed items Nov 8, 2016
@daffl
Copy link
Member Author

daffl commented Nov 11, 2016

I added tests for all other methods now as well.

@ekryski
Copy link
Member

ekryski commented Nov 11, 2016

:shipit:

@daffl daffl merged commit 6a6eb15 into master Nov 11, 2016
@daffl daffl deleted the get-select branch November 11, 2016 03:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants