This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| 1.npm install mongodb -save | |
| 2.确保mongodb服务启动 | |
| 3.ndoe “这个文件名” | |
| */ | |
| var MongoClient = require('mongodb').MongoClient; | |
| var assert = require('assert'); | |
| var url = 'mongodb://localhost:27017/test'; | |
| MongoClient.connect(url, function(err, db) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| /* | |
| api: http://labix.org/mgo api文档的网站 | |
| start: go get go get gopkg.in/mgo.v2 一开始要运行这个安装库 | |
| */ | |
| import ( | |
| "fmt" | |
| //"labix.org/v2/mgo" | |
| //"labix.org/v2/mgo/bson" | |
| "gopkg.in/mgo.v2" |