MongoDB is JSON Document:

How to start MongoDB client:

mongod //start the server

mongo // start the cli

How to restore a database:

mongorestore can create a new database or add data to an existing database.

If you restore to an existing database, mongorestore will only insert into the existing database, and does not perform updates of any kind. If existing documents have the same value _id field in the target database and collection, mongorestore will not overwrite those documents.

Read More:http://docs.mongodb.org/manual/reference/program/mongorestore/

Download the resoure: http://poeticoding.com/downloads/mongodb/mongodb_poeticoding_blog.zip

How to import json file into database:

mongoimport --db simple --collection people --jsonArray data.json

Read More: http://docs.mongodb.org/manual/reference/program/mongoimport/

Simple commands:

//show all the database:
show dbs; //show all collections:
show collections; //create or use one database
use <database_name>

Insert:

The data you have:

{
title: "My first blog post",
author:{
firstName: "YY",
lastName: "KK",
email: "yy.kk@yykk.com"
},
tags: ["coding", "database"],
pubData: new Date
}

Cmd:

//insert into the posts collection
db.posts.insert({
title: "My first blog post",
author:{
firstName: "YY",
lastName: "KK",
email: "yy.kk@yykk.com"
},
tags: ["coding", "database"],
pubData: new Date
});

Note: _id should be unique.

Find:

//get the oldest inserted data
db.posts.findOne();
//get all the data
db.posts.find();
db.posts.find().count(); //count the amount
db.posts.find().pretty(); //make output looks pretty
//Find according to the criteria

//Find the title which is AngularJS
db.posts.find({title: "AngularJS"}); //Find the title whcih contains AngularJS
db.posts.find({title: /AngularJS/i});
//Find title contains 'ios', only show title, not _id in the result
db.posts.find({title: /ios/i}, {title:, _id: });

Javascript code for this: (something should looks like)

    Posts.find({title: /ios/i}).select("title").exec(function(err, data) {
response.json(, data);
})

[MongoDB] Insert, find -- 1的更多相关文章

  1. mongodb insert()、save()的区别

    mongodb 的 insert().save()  ,区别主要是:若存在主键,insert()  不做操作,而save() 则更改原来的内容为新内容. 存在数据:  { _id : 1, " ...

  2. MongoDB insert/update/one2many案例

    以博文与评论为例,博文有标题内容,对应多个评论,评论有评论人.评论内容等. ()插入一条博文: db.blog.insert( {','title':'this is blog title1','co ...

  3. MongoDB insert performance rapidly dropping

    http://dba.stackexchange.com/questions/65554/mongodb-insert-performance-rapidly-dropping http://www. ...

  4. 【翻译】MongoDB指南/CRUD操作(二)

    [原文地址]https://docs.mongodb.com/manual/ MongoDB CRUD操作(二) 主要内容: 更新文档,删除文档,批量写操作,SQL与MongoDB映射图,读隔离(读关 ...

  5. MongoDB - basic

    mongoDB basic from:http://www.tutorialspoint.com/mongodb prject:https://github.com/chenxing12/l4mong ...

  6. 通过mongodb客户端samus代码研究解决查询慢问题

    最近有项目需要用到mongodb,于是在网上下载了mongodb的源码,根据示例写了测试代码,但发现一个非常奇怪的问题:插入记录的速度比获取数据的速度还要快,而且最重要的问题是获取数据的速度无法让人接 ...

  7. mongodb学习2---常用命令解析

    1,mongodb insert()和save()的相同点和区别区别:若新增的数据中存在主键 ,insert() 会提示错误,而save() 则更改原来的内容为新内容.insert({_id : 1, ...

  8. mongodb(基础用法)

    驱动和客户端库 https://mongodb-documentation.readthedocs.org/en/latest/ecosystem/drivers.html#id2 https://m ...

  9. mongodb 和 mysql 的对照

    In addition to the charts that follow, you might want to consider the Frequently Asked Questions sec ...

随机推荐

  1. 项目管理及自动构建工具Maven

    项目管理及自动构建工具Maven 一.Maven安装.目录结构.cmd命令1.下载安装apache-maven-3.2.3-bin.zip下载:http://maven.apache.org/down ...

  2. ansible控制windows的官方翻译

    Ansible控制windows 1.    Windows下如何工作 在ansible控制linux的时候,用的是ssh的方式,在windows中,使用的是power shell,在客户端机器上也是 ...

  3. DOM笔记(五):JavaScript的常见事件和Ajax小结

    一.常见事件类型 1.鼠标事件 事件名称 说明 onclick 鼠标单击时触发 ondbclick 鼠标双击时触发 onmousedown 鼠标左键按下时触发 onmouseup 鼠标释放时触发 on ...

  4. mybatis系列-15-查询缓存

    15.1     什么是查询缓存 mybatis提供查询缓存,用于减轻数据压力,提高数据库性能. mybaits提供一级缓存,和二级缓存. 一级缓存是SqlSession级别的缓存.在操作数据库时需要 ...

  5. 移动开发必备!15款jQuery Mobile插件

    移动互联网的发展,来自PC端的网页并不能完全自适应移动端页面需求,使得响应式设计体验产生并成为潮流,也正是这样一种需求,促成了jQuery Mobile的流行.jQuery Mobile这样一款基于j ...

  6. Linux-sort用法

    本文为转载,原地址:http://www.cnblogs.com/dong008259/archive/2011/12/08/2281214.html sort命令是帮我们依据不同的数据类型进行排序, ...

  7. ios开发APP必须要了解的基本配置

    1,配置开发版本 AdHoc开发版,AppStore正式版 2,oc的宏转swift //常量=>ObjectC宏 letLoadingTip="加载中..." letiOS ...

  8. 32+激发灵感的HTML5/CSS3网页设计教程

      HTML5是寄托在HTML4基础上取得了的广泛成就.这不仅意味着你不必完全放弃现有的一些标记,而是可以借鉴,以加强 它. CSS3也以同样的方式在互联网内容的安排下,提供了它的柔韧性.CSS3是开 ...

  9. openstack network

  10. 第二百三十六天 how can I 坚持

    太冷了,羽绒服没帽子,冻的耳朵疼. 她今天没有上班,原来是调休了. 其实应该是想到点啥,就应该写下,到晚上写就又忘了,什么都不记得了,这就是个需求吧. 睡觉.