Tea*_*ulo 1 mongodb node.js typescript typeorm nestjs
我试过使用
userRepository.find({
where: [
{
email: 'giberish@gmail.com',
},
{
username: 'thisismyusername',
},
]
});
Run Code Online (Sandbox Code Playgroud)
就像 typeorm 文档中解释的那样,但我收到此错误:
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'
Run Code Online (Sandbox Code Playgroud)
我认为您的示例仅适用于 SQL 数据库。对于 mongo,您需要添加运算符$or或$and在您的 where 条件中:
userRepository.find({
where: {
$or: [
{
email: 'giberish@gmail.com',
},
{
username: 'thisismyusername',
},
]
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2382 次 |
| 最近记录: |