您现在的位置是:主页 > news > 桂林建设银行招聘网站/恶意点击推广神器
桂林建设银行招聘网站/恶意点击推广神器
admin2025/4/19 16:42:02【news】
简介桂林建设银行招聘网站,恶意点击推广神器,东莞网站建设_东莞网页设计】,关键词搜索优化文章目录查询某博客下评论以及评论的人的用户名查询某博客下用户名为admin的评论以及评论内容排除不需要的字端多次 lookup参考查询某博客下评论以及评论的人的用户名 需要 comment 和 userProfile 连接查询 db.getCollection(comment).aggregate([{$lookup: {from: userProf…
桂林建设银行招聘网站,恶意点击推广神器,东莞网站建设_东莞网页设计】,关键词搜索优化文章目录查询某博客下评论以及评论的人的用户名查询某博客下用户名为admin的评论以及评论内容排除不需要的字端多次 lookup参考查询某博客下评论以及评论的人的用户名
需要 comment 和 userProfile 连接查询
db.getCollection(comment).aggregate([{$lookup: {from: userProf…
文章目录
- 查询某博客下评论以及评论的人的用户名
- 查询某博客下用户名为admin的评论以及评论内容
- 排除不需要的字端
- 多次 lookup
- 参考
查询某博客下评论以及评论的人的用户名
需要 comment 和 userProfile 连接查询
db.getCollection('comment').aggregate([{$lookup: {from: 'userProfile',localField: 'senderId',foreignField: '_id',as: '评论人'}}, {$match: { 'blogId': ObjectId("6131ac305ee3cf8a4bf1c63a") }}])
查询某博客下用户名为admin的评论以及评论内容
在 $match 中 用 as 的值当作 另一个表 使用 [as.xxx]:xxx进行筛选
db.getCollection('comment').aggregate([{$lookup: {from: 'userProfile',localField: 'senderId',foreignField: '_id',as: '评论人'}}, {$match: {'blogId': ObjectId("6131ac305ee3cf8a4bf1c63a"),"评论人.username": 'admin' }}])
排除不需要的字端
db.xxx.aggregate([{$lookup: {from: 'userProfile',localField: 'senderId',foreignField: '_id',as: 'sender'}}, {$match: {'blogId': ObjectId("6131ac305ee3cf8a4bf1c63a")}},{$project:{'sender.password':0,'sender.lastUpdate':0,'sender.thumbsUp':0,'sender.thumbsDown':0,'sender.mail':0,}}
])
多次 lookup
db.getCollection('secondComment').aggregate([{$lookup: {from: 'userProfile',localField: 'senderId',foreignField: '_id',as: 'sender'}}, {$match: {'blogId': ObjectId("6131ac305ee3cf8a4bf1c63a"),}}, {$lookup: {from: 'userProfile',localField: 'at',foreignField: '_id',as: 'AT'}},{$project:{'sender.password':0,'sender.lastUpdate':0,'sender.thumbsUp':0,'sender.thumbsDown':0,'sender.mail':0,'AT.password':0,'AT.lastUpdate':0,'AT.thumbsUp':0,'AT.thumbsDown':0,'AT.mail':0,}}
])