johnmalkovitch
johnmalkovitch

Reputation: 375

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?

Upvotes: 5

Views: 769

Answers (1)

Tristan Foureur
Tristan Foureur

Reputation: 1657

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

Upvotes: 3

Related Questions