[关闭]
@JunQiu 2018-10-30T01:48:37.000000Z 字数 3913 阅读 1058

mongoDataModule、schema、适用场景 、facebookApi

summary_2018/06 mongodb other

1、日常工作


2、技术学习


  1. db.createCollection("students", {
  2. validator: {
  3. $jsonSchema: {
  4. bsonType: "object",
  5. required: [ "name", "year", "major", "gpa" ],
  6. properties: {
  7. name: {
  8. bsonType: "string",
  9. description: "must be a string and is required"
  10. },
  11. gender: {
  12. bsonType: "string",
  13. description: "must be a string and is not required"
  14. },
  15. year: {
  16. bsonType: "int",
  17. minimum: 2017,
  18. maximum: 3017,
  19. exclusiveMaximum: false,
  20. description: "must be an integer in [ 2017, 3017 ] and is required"
  21. },
  22. major: {
  23. enum: [ "Math", "English", "Computer Science", "History", null ],
  24. description: "can only be one of the enum values and is required"
  25. },
  26. gpa: {
  27. bsonType: [ "double" ],
  28. minimum: 0,
  29. description: "must be a double and is required"
  30. }
  31. }
  32. }
  33. }
  34. })
  1. db.createCollection( "contacts",
  2. { validator: { $or:
  3. [
  4. { phone: { $type: "string" } },
  5. { email: { $regex: /@mongodb\.com\$/ } },
  6. { status: { $in: [ "Unknown", "Incomplete" ] } }
  7. ]
  8. }
  9. } )


MongoDB 特性 介绍
事务支持 MongoDB目前只支持单文档事务,需要复杂事务支持的场景暂时不适合
灵活的文档模型 BSON格式存储最接近真实对象模型,对开发者友好,方便快速开发迭代
高可用复制集 满足数据高可靠、服务高可用的需求,运维简单,故障自动切换
可扩展分片集群 海量数据存储,服务能力水平扩展
高性能 mmapv1、wiredtiger、mongorocks(rocksdb)、in-memory 等多引擎支持满足各种场景需求
强大的索引支持 地理位置索引可用于构建 各种 O2O 应用、文本索引解决搜索的需求、TTL索引解决历史数据自动过期的需求
Gridfs 解决文件存储的需求
aggregation & mapreduce 解决数据分析场景需求,用户可以自己写查询语句或脚本,将请求都分发到 MongoDB 上完成、

大家可以看一下这篇知乎:
MongoDB 等 NoSQL 与关系型数据库相比,有什么优缺点及适用场景?


3、思考与总结

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注