小编MrV*_*inz的帖子

sailsjs/waterline查询"where"不为空

那里,

在进入hacky/cutom方式之前,我想知道是否有内置的query方法来检查空/非空的多对多关系,因为我在谷歌和文档上都没有成功.

如果我采用doc中的示例,让我想象一下,只有当他有一个Pet或Retrive a Pet而没有任何所有者通过查询时,我才想要检索用户.

// A user may have many pets
var User = Waterline.Collection.extend({

  identity: 'user',
  connection: 'local-postgresql',

  attributes: {
    firstName: 'string',
    lastName: 'string',

    // Add a reference to Pet
    pets: {
      collection: 'pet',
      via: 'owners',
      dominant: true
    }
  }
});

// A pet may have many owners
var Pet = Waterline.Collection.extend({

  identity: 'pet',
  connection: 'local-postgresql',

  attributes: {
    breed: 'string',
    type: 'string',
    name: 'string',

    // Add a reference to User
    owners: {
      collection: 'user',
      via: 'pets' …
Run Code Online (Sandbox Code Playgroud)

sails.js waterline

5
推荐指数
1
解决办法
1723
查看次数

标签 统计

sails.js ×1

waterline ×1