如何在mongodb的typeorm中使用“ OR”运算符

时间:2019-02-20 16:57:34

标签: node.js mongodb typescript nestjs typeorm

我尝试使用

id

就像在typeorm文档中解释的那样,但出现此错误:

form-check

1 个答案:

答案 0 :(得分:1)

我认为您的示例仅适用于SQL数据库。对于mongo,您需要在where条件中添加运算符$or$and

userRepository.find({
  where: {
    $or: [
      {
        email: 'giberish@gmail.com',
      },
      {
        username: 'thisismyusername',
      },
    ]
  }
});