1. Use or create a database:

use wandRecorder

You will use keyword to create or fetch a exicting database.

2. Find all documents in the database.

db.wands.find()

You already start with db keywrod. Then follow your collection name, here is 'wands', find() method will return all the documents in that collection.

3. insert document to the collections:

db.wands.insert({name: 'Dream Bender', creator: 'Foxmond'})

Use insert() metod to insert json data to the collection as a document.

4. Find a value in the collections:

db.wands.find({name: 'Storm Seeker'})

You can pass the json object or Bson object into the find method.

http://bsonspec.org/

Result:

{
"_id": ObjectId('d0a77e57a0544ec7ad5a740b'),
"name": "Storm Seeker",
"creator": "Olivemist",
"level_required": 96,
"price": 55.99,
"powers": [
"Wind",
"Static"
],
"damage": {
"magic": 2,
"melee": 5
}
}

5. The data type not necessary to be array, number or string, they canbe Object, Date also:

db.wands.insert({
"name": "Dream Bender",
"creator": "Foxmond",
"level_required": 10,
"price": 34.9,
"powers": ["Fire","Love"],
"damage": {"magic": 4, "melee": 2}
});

6. Find value in a array:

db.wands.find({powers: 'Fire'})

最新文章

  1. soapui中文操作手册(二)----通过您的WSDL请求创建一个测试
  2. 一篇很全面的freemarker教程
  3. 【体系结构】Oracle参数介绍
  4. codeforces A. The Wall 解题报告
  5. 在GridControl控件中使用SearchLookUpEdit构建数据快速输入
  6. select组件2
  7. js 控制台的错误提示
  8. [转]ARM/Thumb/Thumb-2
  9. typedef struct 是什么意思
  10. 利用GeoIP数据库及API进行地理定位查询 Java
  11. 原生Js交互之DSBridge
  12. Everything at Once
  13. 【数论】 快速幂&&矩阵快速幂
  14. Python-lambda表达式和推导式
  15. 【python接口自动化-requests库】【一】requests库安装
  16. hive的select重命名字段显示成中文
  17. 数组的splice方法
  18. Beta阶段DAY1
  19. php switch
  20. 原生js封装十字参考线插件(一)

热门文章

  1. sql - Invalid object name 'dbo.in$'
  2. iOS-点击视图,视图背景颜色随机更改
  3. Hibernate中HQL语句中list与iterate区别
  4. Semaphore (通常用于限制可以访问某些资源(物理或逻辑的)的线程数目)
  5. int, NSInteger, NSUInteger, NSNumber的区别
  6. Linux下修改键盘默认布局
  7. linux 配置 sphinx 全文搜索引擎
  8. Flowplayer-一款免费的WEB视频播放器 转 - helloweba.com
  9. python使用platform模块获取系统环境并去除换行符
  10. jquery获取浏览器的高度和宽度