In my Loopback setup, I have two models named Permissions and langs_translate that I am working with in a loop.
Here are the structure of the tables:
Permissions:
--------------------------
| id | icon | link |
--------------------------
| 1 | dashboard | home |
--------------------------
| 2 | users | users |
--------------------------
| 3 | inbox | inbox |
--------------------------
langs_translate:
-------------------------------------------------------
| id | label | permission_id | lang | translate |
-------------------------------------------------------
| 1 | HOME_TXT | 1 | eng | Dashboard |
-------------------------------------------------------
| 2 | USERS_TXT | 2 | eng | Users |
-------------------------------------------------------
| 3 | INBOX_TXT | 3 | eng | Inbox |
-------------------------------------------------------
| 4 | USERS_TXT | 2 | heb | לקוחות |
-------------------------------------------------------
| 5 | INBOX_TXT | 3 | heb | הודעות |
-------------------------------------------------------
| 6 | HOME_TXT | 1 | heb | לוח בקרה |
-------------------------------------------------------
I am trying to retrieve the "icon" from the permission table and then connect to the lang_translate table using the key "permission_id" to fetch the field "label". However, the data is only being fetched from the permission table. I am currently using the following code to retrieve the data:
$rootScope.menus = Permissions.find({
include:
{"relation": "langsTranslates"},
filter: {
where: {
lang : "heb"
}
}
}, function(data){
console.log(data);
});
Any help on this matter would be greatly appreciated.