Overview

The examples in this guide use the restaurants collection in the test database.

The following is a sample document in the restaurants collection:

{
"address": {
"building": "1007",
"coord": [ -73.856077, 40.848447 ],
"street": "Morris Park Ave",
"zipcode": "10462"
},
"borough": "Bronx",
"cuisine": "Bakery",
"grades": [
{ "date": { "$date": 1393804800000 }, "grade": "A", "score": 2 },
{ "date": { "$date": 1378857600000 }, "grade": "A", "score": 6 },
{ "date": { "$date": 1358985600000 }, "grade": "A", "score": 10 },
{ "date": { "$date": 1322006400000 }, "grade": "A", "score": 9 },
{ "date": { "$date": 1299715200000 }, "grade": "B", "score": 14 }
],
"name": "Morris Park Bake Shop",
"restaurant_id": "30075445"
}

Use the following procedure to populate the restaurants collection.            populate vt. 居住于;构成人口;移民于;殖民于

Prerequisites

You must have a running mongod instance in order to import data into the database.

Procedure

Retrieve the restaurants data.

Retrieve the dataset from https://raw.githubusercontent.com/mongodb/docs-assets/primer-dataset/primer-dataset.json and save to a file named primer-dataset.json.

复制链接,直接放到迅雷里面下载

Import data into the collection.

In the system shell or command prompt, use mongoimport to insert the documents into the restaurants collection in the test database.

If the collection already exists in the test database, the operation will drop the restaurants collection first.

mongoimport --db test --collection restaurants --drop --file ~/downloads/primer-dataset.json

The mongoimport connects to a mongod instance running on localhost on port number 27017.

The--file option provides the path to the data to import, in this case, ~/downloads/primer-dataset.json.

To import data into a mongod instance running on a different host or port, specify the hostname or port by including the --host and the --port options in your mongoimport command.

F:\DataBase\MongoDB\test>mongoimport --db test --collection restaurants --drop -
-file ../primer-dataset.json
2017-02-28T18:43:05.680+0800 connected to: localhost
2017-02-28T18:43:05.694+0800 dropping: test.restaurants
2017-02-28T18:43:07.160+0800 imported 25359 documents

最新文章

  1. Java项目往数据库中插入数据,出现中文乱码
  2. Java算法-堆排序
  3. 剑指Offer:面试题14——调整数组顺序使奇数位于偶数前面(java实现)
  4. sql 泡沫 或者 递归查询
  5. QML学习笔记之三
  6. createSQLQuery与createQuery的区别
  7. JS--图片轮播效果
  8. WPF笔记(2.7 文字布局)——Layout
  9. gcc的bug? c++模板类中友元函数的訪问权限问题
  10. Javascript实现简单跨域调用
  11. linux下tomcat无法访问问题(换一种说法:无法访问8080端口)
  12. C#之面向对象的特性
  13. Integer 比较忽略的问题
  14. css--纵向margin设置auto和百分数真的无效吗?
  15. Vue系列之 => vue组件创建
  16. App.js实现使用js开发app的应用,此文是中文文档
  17. 再玩 DevStack(Mitaka版)- 基于 trystack.cn 源
  18. 菜鸟学Java(十一)——GET与POST
  19. Hamburgers
  20. golang自定义返回error

热门文章

  1. Redis介绍、安装部署、操作
  2. PHP中对hmac_sha1签名算法的实现方法
  3. redis五种数据结构的指令
  4. STM32IAP升级-----编写IAP升级遇到的问题总结
  5. poj 2488 A Knight's Journey(dfs+字典序路径输出)
  6. dexposed框架Android在线热修复
  7. 使用Swing组件编写一个支持中文文本编辑程序ChineseTextEdit.java
  8. DBMS_XPLAN详细说明
  9. 51nod 1572 宝岛地图 (预处理四个方向的最大步数优化时间,时间复杂度O(n*m+k))
  10. 【算法】Floyd-Warshall算法(任意两点间的最短路问题)(判断负圈)