Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

through associations in sails.js

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?

like image 578
johnmalkovitch Avatar asked Oct 19 '22 14:10

johnmalkovitch


1 Answers

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

like image 52
Tristan Foureur Avatar answered Oct 23 '22 07:10

Tristan Foureur