node.js - 通过 sails.js 中的关联

标签 node.js associations sails.js waterline

前一段时间我问如何执行“通过协会”。 我有以下表格:

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   |     | 
+-----------+--------------+------+-----+

答案就在那里:Sails.js associations .

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

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

关于node.js - 通过 sails.js 中的关联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29562147/

相关文章:

ruby-on-rails - 属于多个模型的模型的 CRUD 方法 Rails

ruby-on-rails - rails : Find entity by many-to-many association

javascript - json 被转换为 BSON

mysql - mysql "serverStatus: 34"响应 sails.js 中的水线 orm 是什么意思?

node.js - 在多个 kubernetes pod/实例中处理 Redis KUE 作业

sql - 使用可选参数运行 SQL 查询的最佳方式是什么?

ruby-on-rails - Rails 不尊重 has_one 的模型关联

angularjs - 在同一端口上同时运行 Angular Web App 和 NodeJS 服务器?

node.js - 从非 AWS node.js 应用程序连接到 AWS Elasticsearch

javascript - 在sails.js 中更改默认蓝图操作的最佳实践