通过 sails.js 中的协会

through associations in sails.js

前一段时间我问如何执行"Through Associations"。 我有以下 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   |     | 
+-----------+--------------+------+-----+

答案就在那里:

现在我在想,如果我在 genres_radios table 中有一个新字段,例如:

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

如何在进行连接时获取该属性?

尚未实施。引用 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