首页 > 其他分享 >查询

查询

时间:2023-02-06 09:01:15浏览次数:35  
标签:projection db 查询 query true options

查询多条记录

语法格式:
db.collection.find(query, projection, options)
query为查询条件
projection为展示行规则
options为其他条件

使用

db.getCollection("books").find({}, {title: true, tag: true})
当titile和tag设置为true时则在查询结果中隐藏这些行
id为1时,其他字段必须是1,id为0时,其他字段可以是0
未使用前:
image
使用后:
image

查询单条记录

语法格式
db.collection.findOne(query, projection, options)

使用

db.getCollection("books").findOne({
})

条件查询

标签:projection,db,查询,query,true,options
From: https://www.cnblogs.com/lyraHeartstrings/p/17094373.html

相关文章