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
Added ability to specify what to populate on save() #1055
Added ability to specify what to populate on save() #1055
Conversation
Hey @tobalsgithub, did you branch @nkibler7's save-populate-feature branch? I don't see his commits in this PR only 1 commit from you... |
Oh, no, I just forked the main waterline repo and created all his changes in one commit. Need me to do it the other way? |
I think it would be fair thing to do as then the PR would reflect the history of the changes (and their author). |
f65ec16
to
aabdf90
Compare
Ok, tried again. Is this what you were thinking? |
Much better :) |
@tobalsgithub, would you mind adding a couple of tests to assert:
Perhaps in https://github.com/balderdashy/waterline/tree/master/test/integration? |
Happy to try. I took a peak at this and think there should be 3 tests.
It's not at all clear to me how I should go about this though. Any guidance on what I can look at to determine if the associations are getting populated? |
To give a bit more context, I'm in https://github.com/balderdashy/waterline/tree/master/test/integration/model/save.js. From looking at the other tests, I'm not sure how I can tell if the associations are getting populated just by calling The other tests in this file have stubbed out the adapter methods. Is there a particular adapter method I could stub that would be useful here? Or, can I reuse one of the ones already stubbed? |
Hey @tobalsgithub, you are right, 3 tests! After calling Yes, you can reuse the ones already stubbed. |
Hey @dmarcelino, that's what I originally thought, but either it doesn't work or I'm not understanding how to set it up. I added a car collection and associated it with the person collection in order to test populating only the car collection and not the pet collection. But it appears that after adding a couple instances of these models to the person model, regardless of which options are passed into the save function, all associations still exist. From looking at the actual I thought about checking All 3 of my tests are setup the same way:
But regardless of how I call save,
|
Is it worth using the stubs from https://github.com/balderdashy/waterline/blob/master/test/integration/model/association.add.manyToMany.object.js? In those tests the associations seem to work fine... |
See what you think of this. I'm sort of guessing that the adapter.find method gets called for each populate. Let me know if that's wrong. |
Hey @dmarcelino, |
@tobalsgithub, apologies, I've been busy and forgot this PR 😓 😊 Can you please merge the latest master and fix the merge conflicts? Currently it's not possible to merge... @devinivy, can you also take a look please? |
Looks like it can be merged now. Let me know if there are any issues. |
I like what you've done with Finally checked the tests and they looked good to me. ✅ @devinivy will you do the honours? UPDATE: @tobalsgithub, would you mind putting some docs together in https://github.com/balderdashy/waterline-docs? |
It looks good to me. I do want to make sure that docs get written though! |
@devinivy, can the docs be written after the merge? |
Yep– after merge and before publish should be okay :) |
Added ability to specify what to populate on save()
Cool! Thanks @tobalsgithub and @nkibler7! |
Changes Unknown when pulling d16a65f on tobalsgithub:save-populate-feature into ** on balderdashy:master**. |
This is the same as #954 but with the function signature changed to have
cb
as the last parameter.All credit to @nkibler7.