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'})

[MongoDB] Introduce to MongoDB的更多相关文章

  1. mongoDB操作命令及mongoDB的helper

    此项目已开源,开源地址是: http://mongodbhelper-csharp.googlecode.com/svn/trunk/ mongodb的helper using System; usi ...

  2. mongoDB & Nodejs 访问mongoDB (一)

    最近的毕设需要用到mongoDB数据库,又把它拿出来再学一学,下盘并不是很稳,所以做一些笔记,不然又忘啦. 安装 mongoDB & mongoVUE mongoDB: https://www ...

  3. mongodb系列之--mongodb 主从配置与说明

    一.为什么要配置mongodb的主从: 1.做主从,可以说是做数据的备份,有利于故障的恢复 2.做主从,可以做到读写分离,主节点负责写操作,从节点负责读操作,这样就把读写压力分开,保证系统的稳定性. ...

  4. java操作mongodb & springboot整合mongodb

    简单的研究原生API操作MongoDB以及封装的工具类操作,最后也会研究整合spring之后作为dao层的完整的操作. 1.原生的API操作 pom.xml <!-- https://mvnre ...

  5. 学习MongoDB 一:MongoDB 入门(安装与配置)

    一.简介 MongoDB一种非关系型数据库(NoSql),是一种强大.灵活.可扩展的数据存储方式,因为MongoDB是文档模型,自由灵活很高,可以让你在开发过程中畅顺无比,对于大数据量.高并发.弱事务 ...

  6. Mongodb 笔记01 MongoDB 简介、MongoDB基础知识、启动和停止MongoDB

    MongoDB 简介 1. 易于使用:没有固定的模式,根据需要添加和删除字段更加容易 2. 易于扩展:MongoDB的设计采用横向扩展.面向文档的数据模型使它能很容易的再多台服务器之间进行分割.自动处 ...

  7. MongoDB · 引擎特性 · MongoDB索引原理

    MongoDB · 引擎特性 · MongoDB索引原理数据库内核月报原文链接 http://mysql.taobao.org/monthly/2018/09/06/ 为什么需要索引?当你抱怨Mong ...

  8. MongoDB小结01 - MongoDB简介

    我们为什么要去学习MongoDB MongoDB是一种强大.灵活.可扩展的数据存储方式. 丰富的数据模型 MongoDB是面向文档的数据库,不是关系型数据库.它将原来'行'(row)的概念换成了更加灵 ...

  9. mongodb基本命令,mongodb集群原理分析

    mongodb基本命令,mongodb集群原理分析 集合: 1.集合没有固定数据格式. 2. 数据: 时间类型: Date() 当前时间(js时间) new Date() 格林尼治时间(object) ...

随机推荐

  1. cxf webservice异步调用

    http://blog.csdn.net/changpingchen/article/details/9048347 http://www.oschina.net/question/780719_12 ...

  2. iOS中的设计模式

    一. MVC MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用一种业务逻辑.数据.界面显示分离 ...

  3. c/c++内存机制(一)(转)

    转自:http://www.cnblogs.com/ComputerG/archive/2012/02/01/2334898.html 一:C语言中的内存机制 在C语言中,内存主要分为如下5个存储区: ...

  4. JavaScript的“闭包”到底是什么

    在JavaScripot函数闭包的定义中,一般都有一个outer 函数,一个inner函数.那么“闭包”到底是指outer函数呢,还是指inner函数? 从官方定义来看,并不清楚:A closure  ...

  5. 【POJ1753】Flip Game

    [题目大意] 有一个4x4规格的一个棋盘,现在有16个一面黑一面白的棋子分布在这个棋盘上. 翻转一个棋子能够使它以及它上下左右的四个棋子从黑变白,从白变黑. 现在问你至少要经过多少次操作才能够使得整个 ...

  6. windows 7下安装python+mongodb

    1. python安装 下载:http://python.org/download/ 直接双击安装,安装完后将路径加入系统环境变量path中. 2. mongodb安装 下载:http://www.m ...

  7. jquery 的日期时间控件(年月日时分秒)

    <!-- import package --> <script type="text/javascript" src="JS/jquery.js&quo ...

  8. git stash 保存修改现场

    用途:当你正在分支上做一个项目的时候,突然必须停下来去做别的事情,但因为没有此项目还没改好,所以不想commit 就可以保留现场,等忙完后再回复现场继续修改. bug处理保存开发现场$ git sta ...

  9. 在PyQt4中使用matplotlib

    matplotlib作为Python中著名的数据可视化工具,其官网也提供了在PyQt4中使用的源码,这里举一个应用实例,以备不时之需. 1) 利用Qt Designer创建GUI界面 Demo的GUI ...

  10. decimal类型数据如何保留两位小数

    日常开发中,decimal作为货币类型,经常会处理保留两位小数的问题. 本站整理两种,decimal类型保留两位小数的方法. 第一种: decimal d = 46.28111m;string res ...