How to perform SQL Joins and Relations in Sails.js and Waterline?

前端 未结 2 868
刺人心
刺人心 2020-12-29 05:26

Can anyone guide me on how to setup relational schema & performs joins in sails.js?

2条回答
  •  攒了一身酷
    2020-12-29 05:31

    The example from particle banana works but should actually use "new" like "var instance = new User._model(values)". I'm using the following code and it works.

    Accounts.query(query, function(err, accounts) {
      if (err)
        return fn(err);
    
      accounts = _.map(accounts, function(account) {
        return new Accounts._model(account);
      });
    
      fn(null, accounts);
    });
    

提交回复
热议问题