Created
November 7, 2014 21:35
-
-
Save uncletammy/a822c8bf926ecb8ecd09 to your computer and use it in GitHub Desktop.
One-To-One Associations Issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Pet.js | |
* | |
* @description :: TODO: You might write a short summary of how this model works and what it represents here. | |
* @docs :: http://sailsjs.org/#!documentation/models | |
*/ | |
module.exports = { | |
attributes: { | |
owner: { | |
model: 'user' | |
} | |
} | |
}; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dude@littleDude:~/node/trashApp$ rm .tmp/localDiskDb.db | |
dude@littleDude:~/node/trashApp$ sails console | |
info: Starting app in interactive mode... | |
info: Welcome to the Sails console. | |
info: ( to exit, type <CTRL>+<C> ) | |
sails> User.create({name:'rick',petName:{name:'spot'}}).exec(console.log); | |
undefined | |
sails> null { name: 'rick', | |
petName: 1, | |
createdAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
updatedAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
id: 1 } | |
User.find().populate('petName').exec(console.log) | |
undefined | |
sails> null [ { petName: | |
{ name: 'spot', | |
createdAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
updatedAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
id: 1 }, | |
name: 'rick', | |
createdAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
updatedAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
id: 1 } ] | |
sails> Pet.find().populate('owner').exec(console.log) | |
undefined | |
sails> null [ { name: 'spot', | |
createdAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
updatedAt: Fri Nov 07 2014 15:33:48 GMT-0600 (CST), | |
id: 1, | |
owner: undefined } ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* User.js | |
* | |
* @description :: TODO: You might write a short summary of how this model works and what it represents here. | |
* @docs :: http://sailsjs.org/#!documentation/models | |
*/ | |
module.exports = { | |
attributes: { | |
petName: { | |
model: 'pet' | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Using versions
Sails.js: v.0.10.5
Waterline: v.0.10.12
Sails-disk: v.0.10.4
Is this expected behavior?