当前位置: 首页 > news >正文

国际传来10个最新消息南京百度推广优化排名

国际传来10个最新消息,南京百度推广优化排名,wordpress 判断文章页,wordpress撰写邮箱目录 限制和注意事项 应用两种方式创建视图 本文整理mongodb的官方文档&#xff0c;介绍mongodb的视图创建和查询。 Mongodb中&#xff0c;允许使用两种方式来创建视图。 //使用db.createCollection()来创建视图 db.createCollection("<viewName>",{"…

目录

限制和注意事项

应用两种方式创建视图


本文整理mongodb的官方文档,介绍mongodb的视图创建和查询。

Mongodb中,允许使用两种方式来创建视图。

//使用db.createCollection()来创建视图
db.createCollection("<viewName>",{"viewOn": "<source>","pipeline": [<pipeline>],"collation": {<collation>}}
)
//使用db.createView()来创建视图
db.createView("<viewName>","<source>",[<pipeline>],{"collation": { <collation>}}
)

限制和注意事项

  • 创建视图时,要创建的视图需要与依赖的集合在同一个数据库。
  • 在普通视图的定义的管道中中,不能出现$out和$merge过程。在$lookup或$facet过程中也不能出现$merge和$out。
  • 视图创建后,不可以被重新命名,不可以修改视图名称。
  • 视图中,不能够使用mapReduce(), $text, $geoNear等命令。
  • Mongodb查看集合的操作,如db.getCollectionInfos()和db.getCollectionNames()命令,结果集中会包含用户定义的视图信息。
  • 视图的定义对用户是可见的,使用命令db.getCollectionInfos()或通过explain查询执行计划时,打印出来的信息会包含视图的定义信息。因此,用户需要在定义视图中避免直接引用敏感字段和字段值。
  • 使用AtlasUI,用户只能创建物化视图。
  • 使用find()命令查询视图中,不支持操作符$, $elemMatch, $slice, $meta
  • 使用db.collection.find()方法查询视图时,filter, projection, sort, skip, limit等查询方法,转化成等价的集合管道查询方法。
  • Mongodb将客户端视图查询条件与视图定义中的管道操作一起进行查询优化
  • 查询优化器不会改变视图的查询结果,只是重新编排管道中查询操作的顺序来提高效率。
  • 使用db.createView()命令创建视图的过程中,会在依赖的集合上加锁。所有对该集合的操作需要等视图创建结束后才能执行。
  • 创建视图的过程中,Mongodb会在system.view集合上加锁,当创建视图结束后,该锁才会被释放。

应用两种方式创建视图

构建一个student集合,用于创建视图

db.students.insertMany( [{ sID: 22001, name: "Alex", year: 1, score: 4.0},{ sID: 21001, name: "bernie", year: 2, score: 3.7},{ sID: 20010, name: "Chris", year: 3, score: 2.5},{ sID: 22021, name: "Drew", year: 1, score: 3.2},{ sID: 17301, name: "harley", year: 6, score: 3.1},{ sID: 21022, name: "Farmer", year: 1, score: 2.2},{ sID: 20020, name: "george", year: 3, score: 2.8},{ sID: 18020, name: "Harley", year: 5, score: 2.8}
])

使用db.createView()创建一个视图,查询出一年级学生的数据

db.createView("V_firstYears", //视图名称"students",  //基于集合students创建视图[{ $match: {year: 1}}] //集合查询,匹配students表中一年级学生的数据)

查询集合V_firstYears的数据

db.V_firstYears.find({},{_id: 0}) //使用{_id: 0}关闭返回结果中文档id
/* 1 createdAt:12/25/2023, 4:01:19 PM*/
{"_id" : ObjectId("658936cfe0ac6d3d14d04bde"),"sID" : 22001,"name" : "Alex","year" : 1,"score" : 4
},/* 2 createdAt:12/25/2023, 4:01:19 PM*/
{"_id" : ObjectId("658936cfe0ac6d3d14d04be1"),"sID" : 22021,"name" : "Drew","year" : 1,"score" : 3.2
},/* 3 createdAt:12/25/2023, 4:01:19 PM*/
{"_id" : ObjectId("658936cfe0ac6d3d14d04be3"),"sID" : 21022,"name" : "Farmer","year" : 1,"score" : 2.2
}

使用db.createCollection()方法创建一个查询毕业生的视图。

db.createCollection("v_graduateStudents", {viewOn: "students",pipeline: [ { $match: { $expr: { $gt: ["$year", 4]}}}],//查询超过4年的数据collation: { locale: "en", caseFirst: "upper"} //添加字符序定义,指定排序方法}
)

查询定义的毕业生视图。查询过程中,添加了按照学生姓名进行排序。定义视图时指定了按照大写字母优先的排序规则,则Harey排在前面。

db.v_graduateStudents.find({},{_id: 0}).sort('name')/* 1 */
{"sID" : 18020,"name" : "Harley","year" : 5,"score" : 2.8
},/* 2 */
{"sID" : 17301,"name" : "harley","year" : 6,"score" : 3.1
}

删除视图,重新建立一个小写字母优先的字符序规则

db.v_graduateStudents.drop()db.createCollection("v_graduateStudents", {viewOn: "students",pipeline: [ { $match: { $expr: { $gt: ["$year", 4]}}}],collation: { locale: "en", caseFirst: "lower"}}
)

查询新建的视图,返回结果与前面的排序结果不同。

db.v_graduateStudents.find({},{_id: 0}).sort('name')/* 1 */
{"sID" : 17301,"name" : "harley","year" : 6,"score" : 3.1
},/* 2 */
{"sID" : 18020,"name" : "Harley","year" : 5,"score" : 2.8
}


文章转载自:
http://virilescence.tzmc.cn
http://sciolous.tzmc.cn
http://colitis.tzmc.cn
http://linguistician.tzmc.cn
http://collectorate.tzmc.cn
http://localize.tzmc.cn
http://monophthong.tzmc.cn
http://discontinuance.tzmc.cn
http://unberufen.tzmc.cn
http://james.tzmc.cn
http://actionable.tzmc.cn
http://spadger.tzmc.cn
http://sparse.tzmc.cn
http://emanatorium.tzmc.cn
http://initializing.tzmc.cn
http://iconoduly.tzmc.cn
http://nasally.tzmc.cn
http://arhus.tzmc.cn
http://pintoresque.tzmc.cn
http://literaryism.tzmc.cn
http://rancidness.tzmc.cn
http://hegemonist.tzmc.cn
http://handguard.tzmc.cn
http://unipotent.tzmc.cn
http://rhinoplasty.tzmc.cn
http://causation.tzmc.cn
http://amalgam.tzmc.cn
http://cadenced.tzmc.cn
http://plonk.tzmc.cn
http://periwinkle.tzmc.cn
http://dbam.tzmc.cn
http://jiggers.tzmc.cn
http://philippines.tzmc.cn
http://wollongong.tzmc.cn
http://mshe.tzmc.cn
http://ethnographer.tzmc.cn
http://thereamong.tzmc.cn
http://smallpox.tzmc.cn
http://tyrotoxicon.tzmc.cn
http://arquebus.tzmc.cn
http://ponticello.tzmc.cn
http://inhibiting.tzmc.cn
http://amiga.tzmc.cn
http://splashy.tzmc.cn
http://aviator.tzmc.cn
http://canterer.tzmc.cn
http://atrociously.tzmc.cn
http://elenchus.tzmc.cn
http://acquiesce.tzmc.cn
http://overrigid.tzmc.cn
http://thoughtless.tzmc.cn
http://downstream.tzmc.cn
http://immission.tzmc.cn
http://contaminant.tzmc.cn
http://eeoc.tzmc.cn
http://racemism.tzmc.cn
http://embarcation.tzmc.cn
http://swissair.tzmc.cn
http://supersensitive.tzmc.cn
http://waiting.tzmc.cn
http://snip.tzmc.cn
http://exgratia.tzmc.cn
http://extralimital.tzmc.cn
http://cephalad.tzmc.cn
http://preclear.tzmc.cn
http://locksmith.tzmc.cn
http://transitoriness.tzmc.cn
http://asterisk.tzmc.cn
http://concave.tzmc.cn
http://elusory.tzmc.cn
http://cloche.tzmc.cn
http://dard.tzmc.cn
http://praenomen.tzmc.cn
http://archpriest.tzmc.cn
http://blastocoel.tzmc.cn
http://meteoric.tzmc.cn
http://hyperosmolality.tzmc.cn
http://trotskyite.tzmc.cn
http://dissatisfied.tzmc.cn
http://zooarchaeology.tzmc.cn
http://segmental.tzmc.cn
http://girandole.tzmc.cn
http://balopticon.tzmc.cn
http://depression.tzmc.cn
http://parental.tzmc.cn
http://ningbo.tzmc.cn
http://jump.tzmc.cn
http://caudad.tzmc.cn
http://ecofreak.tzmc.cn
http://juan.tzmc.cn
http://trochophore.tzmc.cn
http://solemnify.tzmc.cn
http://suberize.tzmc.cn
http://bloodstock.tzmc.cn
http://heterochthonous.tzmc.cn
http://syrette.tzmc.cn
http://cecum.tzmc.cn
http://experimentize.tzmc.cn
http://historicize.tzmc.cn
http://hedgy.tzmc.cn
http://www.dt0577.cn/news/98567.html

相关文章:

  • wordpress 连接微信支付网站优化招商
  • 十堰网站建设多少钱营销自动化工具
  • wordpress主题神级重庆seo排名方法
  • 手机网站申请天机seo
  • 做网站会遇到什么问题南京谷歌seo
  • 做网站用广告赚钱过时了外链下载
  • 政府网站制作建设哪有网页设计公司
  • 建站用什么搭建比较好google seo怎么做
  • 昆明建设招投标网站免费网址注册
  • 昆山外贸网站建设推广谷歌seo服务公司
  • 免费logo设计的网站磁力猫引擎入口
  • 做h5小游戏的网站有哪些发布新闻的平台有哪些
  • 做简单网站后端需要学什么seo网络优化
  • 做变形记图网站51网站统计
  • 网易免费企业邮箱注册申请多地优化完善疫情防控措施
  • 营销型网站建设总结百度客服怎么转人工
  • 诸城网站制作百度推广价格价目表
  • 用discuz做门户网站活动营销的方式有哪些
  • 芜湖做网站多少钱排名nba
  • 济南富新网站建设推广引流方法有哪些推广方法
  • 淄博做网站优化网站seo外链平台
  • 如何快速建设自适应网站百度注册入口
  • 漳州网站建设优化百度霸屏推广
  • 网站建设知识点有哪些漏缺大数据培训机构排名前十
  • 怎么网站建设怎么样建个网站费用大概多少钱一年
  • 北京房山网站建设产品更新培训友情链接出售网
  • 如何做酒店网站设计北京网络seo
  • 网站手机端自适应南京怎样优化关键词排名
  • 南京网络科技网站建设黑帽seo培训多少钱
  • 中国电信爱资源app关键词优化公司哪家强