Assign reference_id when reference object is assigned to model #247

Closed
bioform opened this Issue Mar 29, 2013 · 5 comments

Comments

Projects
None yet
3 participants

bioform commented Mar 29, 2013

For example I have model "Comment" which belongs to "Post" model:

Comment.belongsTo( compound.models.Post, {as: 'post', foreignKey: 'post_id'})

If I create comment as:

Comment.create({post: myPost}, callback)
// "myPost" is instance of "Post" model.

Then "post_id" field is not assigned at all (mongodb adapter)

Owner

1602 commented Apr 11, 2013

Why not use myPost.comments.create instead?

bioform commented Apr 12, 2013

It was just example.
What about:

Comment.create({post: myPost, user: currentUser}, callback)

????

Collaborator

anatoliychakkaev commented Apr 13, 2013

Okay, let's leave it in 'nice-to-have' list. Actually it's just sugar over
existing stuff, but a lot of thing should be done before this feature could
be implemented. Doing it right here and right now is bad idea.

On Fri, Apr 12, 2013 at 8:05 AM, bioform notifications@github.com wrote:

It was just example.
What about:

Comment.create({post: myPost, user: currentUser}, callback)

????


Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/issues/247#issuecomment-16274943
.

bioform commented Apr 18, 2013

Make sure that you use cached relation after such assignment.
No need to query DB if you already assigned object to relation.

Collaborator

anatoliychakkaev commented Apr 18, 2013

Please check test coming with this feature before starting any discussions.
I got tired of endless pointless messages.

On Thu, Apr 18, 2013 at 1:49 PM, bioform notifications@github.com wrote:

Make sure that you use cached relation after such assignment.
No need to query DB if you already assigned object to relation.


Reply to this email directly or view it on GitHubhttps://github.com/1602/jugglingdb/issues/247#issuecomment-16567419
.

Thanks,
Anatoliy Chakkaev

vrcsix pushed a commit to minmb/jugglingdb that referenced this issue May 10, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment