我在组织模型中有以下一行:
await bookshelf
.model('User')
.where({ org_id: this.get('id'), isAdministrator: 1 })
.fetchAll()
.then...
这个管用。它选择具有特定org_id
且isAdministrator
等于1的记录。
我希望更改此.where
行,使其选择具有特定org_id
且(isAdministrator
等于1或isAssociate
等于1)的记录。我该怎么加这个?
我尝试了下面的代码,但是返回了一个错误:TypeError:Bookshelf.Model(。。。)。Where(。。。)。或者Where不是函数
await bookshelf
.model('User')
.where({ org_id: this.get('id'), isAdministrator: 1 })
.orWhere({ org_id: this.get('id'), isAssociate: 1 })
.fetchAll()
.then...
根据文档,您可以在where
查询对象中使用或where
:
.query({where: { org_id: this.get('id'),isAdministrator: 1 },
orWhere: { org_id: this.get('id'), isAssociate: 1 }})