sails js data relationship

2019-07-18 17:38发布

Does sails.js support relationships between models/collections? If so, can someone point to documentation?

For example: I have 2 models

1.Production

production: {
  name: 'string',
  description: 'text'
}

2.Album

album: {
  name: 'string',
  productionID: 'ObjectID'// How do I get to "production"?
}

2条回答
Ridiculous、
2楼-- · 2019-07-18 17:45

Waterline, the ORM for Sails, does support associations between models/collections. However, support for associations is a work in progress. With that being said, the MySQL and Postgresql support is the furthest along.

You may find the unfinished documentation for waterline v0.10 here:

https://github.com/balderdashy/waterline-docs

查看更多
乱世女痞
3楼-- · 2019-07-18 17:46

Sailsjs 0.9.x does not support relationships or associations currently. 0.10 does have a rough outline of this working.

Disclaimer: the 0.10 branch is a constant work in progress and can break on a daily basis as the contributors push code to it, if somethings broken its best to ask in the irc #sailsjs chat or post an issue tagged 0.10 if it truly is broken.

You can install sailsjs v0.10 to give it a try by doing something like the following.. (I'm not in front of my machine to test this but it should work).

   #in your downloads directory or somewhere globally accessible clone the 0.10 branch
   git clone https://github.com/balderdashy/sails -b v0.10 sails;
   cd sails; npm install; npm link;
   #this will install all sails dependencies, and npm link sails to that cloned folder

Once its installed you can then run sails -v and you should get 0.10.

Then its just a matter of generating a new sails app with sails new <appname>

查看更多
登录 后发表回答