You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
User=persist.define("User",{'email': {'type': 'string','primaryKey': true},'name': 'string',}).on("beforeSave",function(self){// have to save and restore email, because // last_id is assigned to it after insertself._email=self.email;}).on("afterSave",function(self){self.email=self._email;deleteself._email;});varComment=persist.define("Comment",{'text': 'string',}).hasOne(User,{'foreignKey': 'user_email'});
What reasons do you have to delete foreignKey when you make reversed association in parent model?
If child.key references parent.id, then parent.id must reference child.key, not child.id.
The text was updated successfully, but these errors were encountered:
The hack with save and restore email is for this line:
https://github.com/nearinfinity/node-persist/blob/master/lib/connection.js#L115
When I try to select
user.comments
I get nothing, query is:As you can see it uses user_id instead of user_email.
I get the results if I delete this line:
https://github.com/nearinfinity/node-persist/blob/master/lib/model.js#L334
What reasons do you have to delete foreignKey when you make reversed association in parent model?
If child.key references parent.id, then parent.id must reference child.key, not child.id.
The text was updated successfully, but these errors were encountered: