Skip to content
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

String to ObjectID type casting in foreign keys (unconfirmed) #13

Open
1602 opened this issue May 23, 2013 · 0 comments
Open

String to ObjectID type casting in foreign keys (unconfirmed) #13

1602 opened this issue May 23, 2013 · 0 comments

Comments

@1602
Copy link
Contributor

1602 commented May 23, 2013

Example:

Event.belongsTo(compound.models.User,{ as: 'user', foreignKey: 'user_id'})
User.hasMany(compound.models.Event, {as: 'events', foreignKey: 'user_id'})
Event.create({user_id: "518aa9bdfb6a877d24000003"})

Above code write "user_id" field as a string to MongoDB.
It should be ObjectID.
And the following code doesn't work:

user.events(function(err, events){
    // events is empty list. I guess it is related with "string" value of event.user_id
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant