MongoDB-管道聚合查询(笔记)

Rosalia ·
更新时间:2024-09-20
· 560 次阅读

db.term.aggregate([
{KaTeX parse error: Expected 'EOF', got '}' at position 24: …ibrary_id:3607}}̲, {limit:5},
{KaTeX parse error: Expected '}', got 'EOF' at end of input: group:{_id:"version", count: {KaTeX parse error: Expected 'EOF', got '}' at position 6: sum:1}̲}}, {sort:{count:-1}}
])

查询样例:
db.getCollection(‘txpfHistory’).aggregate(
[
{
$match : {
‘companyCode’ :‘0000’,
‘channelCode’ : ‘CUCC’,
‘hasHistory’:0
}
},
{ KaTeX parse error: Expected '}', got 'EOF' at end of input: … : {telephone:"telephone"}, count: { KaTeX parse error: Expected 'EOF', got '}' at position 8: sum: 1 }̲ } }, {match:{count:{$gt:2}}}
]
)

db.getCollection(‘tableName’).find(
{
“companyCode”:“0000”,
“result” :{$exists:true},
“channelCode”:“AAA”,
“queryNo”:{
$gte:‘01*’,
$lte:‘10*’
}
}
).sort({“queryNo”:-1}) //根据时间排序
.size() //统计大小

db.getCollection(‘tableName’).aggregate(
{
$match : {
‘queryNo’ :{ gt:′01∗′,gt: '01*' ,gt:′01∗′,lte: ‘10*’ }
}
},
{
‘KaTeX parse error: Expected '}', got 'EOF' at end of input: … time: {substr: [‘KaTeX parse error: Expected 'EOF', got '}' at position 18: …eryNo', 0, 8 ] }̲, …companyCode’,
channelCode: { substr:[′substr: [ 'substr:[′channelCode’, 0, 4 ]}
},
‘sum’ : { ‘KaTeX parse error: Expected 'EOF', got '}' at position 9: sum' : 1}̲ } …sort’:{time:-1}
}
)


作者:weixin_40156790



MongoDB 管道

需要 登录 后方可回复, 如果你还没有账号请 注册新账号