简体   繁体   中英

Sails.js : Joins

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

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 )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM