Sails.js : Joins
Asked Answered
P

1

6
  var obsType = (from lk in db.LookUp
                  join 
                  lt in db.LookUpType
                  on 
                  lk.LookUpTypeId equals lt.LookupTypeId
                  where (lt.FieldName == "OBSType") 
                  && 
                 !(db.OBSSetting.Select(k => k.OBSTypeId)).Contains(lk.Id)
                  orderby
                 (lk.SortOrder ?? decimal.MaxValue)
                 select new LookUpViewModel
                 {
                     Id = lk.Id,
                     Description = lk.Description
                 }).ToList();
  return obsType;

This is the MVC LinQ query, How do write this join query in sails js.

Three different models are used here: (LookUpType,LookUp,OBSSetting).

Anyone please guide to do this task.

Thanks in advance....

Punchinello answered 7/9, 2015 at 4:35 Comment(1)
The Codeformat to display the Query is not good.Irrevocable
R
0

You can use waterline associations to join tables, have a look at this. If it's not working for you, you can go for a raw SQL query (here)

Richthofen answered 4/7, 2016 at 19:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.