Reputation: 1003
Did someone had experience with mapping 2 models with sails.js? I think it would be easier to give example:
Application has many configurations, i would like to map them with relation of appUUID or unique MongoDB id with configurations.
I couldn't find how to do it on waterline(ORM for sails.js) github docs, that's the reason why i am asking this.
Thank you in advance.
Upvotes: 3
Views: 3092
Reputation: 56
use Collection block in attributes for relationship
example of one to many:
at the side of one:
attributes:{
userName:'string',
password:'string',
abc:{
collection:'manySideTable',
via:'xyz'
}
}
at the side of many
attributes:{
userName:'string',
password:'string',
xyz:{
collection:'oneSideTable',
columnName:'FK'
}
}
Upvotes: 1
Reputation: 85
Associations are officially Supported in Waterline
With Sails and Waterline, you can associate models across multiple data stores. This means that even if your users live in PostgreSQL and their photos live in MongoDB, you can interact with the data as if they lived together in the same database. You can also have associations that span different connections (i.e. datastores/databases) using the same adapter. This comes in handy if, for example, your app needs to access/update legacy recipe data stored in a MySQL database in your company's data center, but also store/retrieve ingredient data from a brand new MySQL database in the cloud.
This is in progress, see the issue #124 on the sailsjs Github. There is also a branch on the Waterline Github repo
Upvotes: 2