Node.js 如何在mongodb的TypeForm中使用“OR”运算符
我试过使用Node.js 如何在mongodb的TypeForm中使用“OR”运算符,node.js,mongodb,typescript,nestjs,typeorm,Node.js,Mongodb,Typescript,Nestjs,Typeorm,我试过使用 userRepository.find({ where: [ { email: 'giberish@gmail.com', }, { username: 'thisismyusername', }, ] }); 就像TypeForm文档中解释的那样,但我得到了以下错误: errmsg: 'Error getting filter : Error getting filter BSON field from d
userRepository.find({
where: [
{
email: 'giberish@gmail.com',
},
{
username: 'thisismyusername',
},
]
});
就像TypeForm文档中解释的那样,但我得到了以下错误:
errmsg:
'Error getting filter : Error getting filter BSON field from doc = [{find user} {filter [[{email giberish@gmail.com}] [{username thisismyusername}]]} {returnKey false} {showRecordId false} {$clusterTime [{clusterTime 6660127540193001473} {signature [{hash [184 253 193 112 111 39 205 239 38 92 178 205 149 85 131 136 252 114 180 30]} {keyId 6637077103550398465}]}]}] : not bson []interface {} [[{email craftball@gmail.com}] [{username thisismyusername}]]\n\tat erh/mongonet/bsonutil.go:122\n\tat 10gen/atlasproxy/bson_util.go:32\n\tat 10gen/atlasproxy/commands_security.go:521\n\tat 10gen/atlasproxy/commands.go:653\n\tat 10gen/atlasproxy/commands.go:563\n\tat 10gen/atlasproxy/session_proxy.go:256\n\tat 10gen/atlasproxy/session_proxy.go:702\n\tat 10gen/atlasproxy/session_proxy.go:526\n\tat erh/mongonet/proxy.go:209\n\tat erh/mongonet/proxy.go:104\n\tat erh/mongonet/session.go:82\n\tat src/runtime/asm_amd64.s:2361',
code: 8000,
codeName: 'AtlasError',
name: 'MongoError'
我认为您的示例只适用于SQL数据库。对于mongo,您需要在where条件中添加运算符$或$和:
userRepository.find({
where: {
$or: [
{
email: 'giberish@gmail.com',
},
{
username: 'thisismyusername',
},
]
}
});
我认为您的示例只适用于SQL数据库。对于mongo,您需要在where条件中添加运算符$或$和:
userRepository.find({
where: {
$or: [
{
email: 'giberish@gmail.com',
},
{
username: 'thisismyusername',
},
]
}
});