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.
IMPORTANT NOTE
In the examples used throughout the associations concepts guide, note that all references to Sails model classes are in lowercase. For example, in:
// User.js module.exports = { connection: 'ourMySQL', attributes: { email: 'string', wishlist: { collection: 'product', via: 'wishlistedBy' } } };
the
collection
key is set toproduct
--this is the identity of the Sails model calledProduct
. Whenever models are referenced incollection
,via
,model
orthrough
keys, their lowercased identity names should be used.