through associations in sails.js

2019-06-21 06:09发布

A while ago I asked how to perform the "Through Associations". I have the following tables :

genres
+-----------+--------------+------+-----+
| Field     | Type         | Null | Key |
+-----------+--------------+------+-----+
| id        | int(6)       | NO   | PRI | 
| slug      | varchar(255) | NO   |     |
| parent_id | int(11)      | YES  | MUL | 
+-----------+--------------+------+-----+
genres_radios
+----------+--------+------+-----+
| Field    | Type   | Null | Key |
+----------+--------+------+-----+
| genre_id | int(6) | NO   | MUL |
| radio_id | int(6) | NO   | MUL |
+----------+--------+------+-----+
radios
+-----------+--------------+------+-----+
| Field     | Type         | Null | Key |
+-----------+--------------+------+-----+
| id        | int(5)       | NO   | PRI | 
| slug      | varchar(100) | NO   |     |
| url       | varchar(100) | NO   |     | 
+-----------+--------------+------+-----+

The answer is there : Sails.js associations.

Now I was wondering, if I had a new field in the genres_radios table, for example:

genres_radios
+----------+--------+------+-----+
| Field    | Type   | Null | Key |
+----------+--------+------+-----+
| genre_id | int(6) | NO   | MUL |
| new_field| int(10)| NO   |     |
| radio_id | int(6) | NO   | MUL |
+----------+--------+------+-----+

How would I do to get that attribute while making the join?

1条回答
够拽才男人
2楼-- · 2019-06-21 06:44

It is not implemented yet. Quoting Waterline's documentation :

Many-to-Many Through Associations

Many-to-Many through associations behave the same way as many-to-many associations with the exception of the join table being automatically created for you. This allows you to attach additional attributes onto the relationship inside of the join table.

Coming Soon

查看更多
登录 后发表回答