![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
mongoDB笔记
文章平均质量分 63
杨过悔
这个作者很懒,什么都没留下…
展开
-
第一节 MongoDB介绍及下载与安装
http://www.cnblogs.com/mecity/archive/2011/06/11/2078527.htmlMongoDB是一个介于关系数据库和非关系数据库之间的产品,是非关系数据库当中功能最丰富,最像关系数据库的。他支持的数据结构非常松散,是类似json的bjson格式,因此可以存储比较复杂的数据类型。Mongo最大的特点是他支持的查询语言非常强大,其语法有点类似于面向对象的查转载 2015-09-08 09:31:31 · 334 阅读 · 0 评论 -
120 mongodb collections vs single collection - which one is more efficient?
Single Sharded CollectionThe edited version of the question makes the actual requirement clearer: you have a collection that can potentially grow very large and you want an approach to partition t转载 2016-11-22 10:11:39 · 350 阅读 · 0 评论 -
updates-documents-nested-in-arrays
https://www.nodechef.com/docs/cloud-search/updates-documents-nested-in-arraysQuery and Update documents nested multiple levels in an arrayThe $ positional operator is used to project e转载 2016-11-30 10:20:21 · 294 阅读 · 0 评论 -
mongo数组内唯一索引的问题
之前一直认为通过唯一唯一索引可以确保doc数组字段的每个doc确保唯一(根据某个字段)如:staffs: [staffRoleSchema],const staffRoleSchema = new Schema({ openid: { type: String, index: { unique: true }, sparse: true }, privilege: { ty原创 2016-11-10 10:07:10 · 1674 阅读 · 0 评论 -
mongo配置文件
有一段时间没用mongo了,每次配置都得上官网copy配置文件,这次配置顺便记录下来,主要是记录出现的一个问题 先看看我们目录结构这里我使用最小化的方式配置mongo,详细可以参考官网的doc文档systemLog: destination: file path: "/home/linux/Applications/mongodb/logs/logs.txt"原创 2016-02-07 14:55:38 · 4133 阅读 · 0 评论 -
一些索引的限制
Extra Overhead:Every index occupies some space as well as causes an overhead on each insert, update and delete. So if you rarely use your collection for read operations, it makes sense not to use in转载 2015-10-02 22:10:56 · 388 阅读 · 0 评论 -
解决原子性
mongo并不提供多文档操作原子性事物的功能,所以在建议使用嵌套文档的方式来解决复杂性的文档这样我们就可以通过同文档多操作同一修改的方式来保证原子性,我们可以通过findAndModify的方法来实现这个目地,举个例子,例如我们有个记录商品的文档,在该商品出售时我们需要查看该商品的剩余数量并减1操作,同时在该文档中添加这个购买商品的客户,这一操作必须在同一次更新文档的情况下进行,这原创 2015-10-02 22:00:30 · 351 阅读 · 0 评论 -
两个分析查询的有用函数
1.$explain 使用这个函数可以分析系统查询数据的信息 2.$hint 强制使用某个index例如db.user.find({gender:"M"},{user_name:1,_id:0}).hint({gender:1,user_name:1})原创 2015-10-02 21:42:42 · 282 阅读 · 0 评论 -
利用DBREF实现MongoDB的引用("外键")
Using DBRefsThere are three fields in DBRefs:$ref: This field specifies the collection of the referenced document$id: This field specifies the _id field of the referenced document$db: This is转载 2015-10-02 19:07:27 · 6000 阅读 · 0 评论 -
使用Java 的Mongo API操作doc
整个过程也是比较简单的,就是比较繁琐,这就是OOP的特性!package common;import java.util.function.Consumer;import org.bson.Document;import com.mongodb.Block;import com.mongodb.MongoClient;import com.mongodb.client.原创 2015-10-02 15:54:01 · 587 阅读 · 0 评论 -
mongo groupby 并获取数组里拥有某个属性最大值的对象
原创 2017-11-27 10:43:32 · 1878 阅读 · 0 评论