Closed bsiddiqui closed 9 years ago
No real difference. The difference between .related('admins') and
.admins()is that the former calls
site.admins()and stores the return value as
site.relations.admins. The later just returns a new collection with the right
relatedData` bound.
What do you mean by response for the event?
Sorry I mean what kind of response should .attach()
return?
If I do:
return new Site({id: 1}).admins().attach([1, 2])
.then(function (res) {
console.log(res); // empty array
});
Maybe I have my models setup incorrectly.
Yeah that's the resolution value of triggerThen
I believe. It's really not resolving anything intentionally at the moment. What would you expect/want it to resolve?
I would expect that it would resolve with the model that was created or the collection it was added to
With the way it currently resolves, how would you recommend check if you successfully created the model and respond with it?
What exactly are you looking to get in the end? The Site
? The admins with IDs 1 and 2?
I guess I'd be interested in both since this is hypothetical - how would you do it in either situation?
Well I'm asking because it would be sloppy right now with the need to store both the site
and adminIds
in a variable so you can use them later. I think it makes sense to resolve the collection and I can go commit that if it makes sense.
Yeah that makes sense :+1:
On Thu, Jan 22, 2015 at 3:38 AM Ben Drucker notifications@github.com wrote:
Well I'm asking because it would be sloppy right now with the need to store both the site and adminIds in a variable so you can use them later. I think it makes sense to resolve the collection and I can go commit that if it makes sense.
— Reply to this email directly or view it on GitHub https://github.com/bendrucker/discuss/issues/3#issuecomment-71008060.
In describing attach, the Bookshelf docs show two ways to use the method.
Is there a difference in these two approach? Also, is
attach
supposed to respond with any data?I looked through the source code and it seems like there is an "attached" event but I haven't seen what kind of response it should be giving - I've been getting an empty array.