MongoDB Node.JS Driver 1.4.9 documentation
2017-02-09 10:13
302 查看
db.open(function(err, db) {
摘自
MongoDB Node.JS Driver 1.4.9 documentation
Initialize the database connection.
open(callback)
Examples
An example of a simple single server db connection
摘自
MongoDB Node.JS Driver 1.4.9 documentation
open
Initialize the database connection.open(callback)
Arguments: | callback (function) – this will be called after executing this method. The first parameter will contain the Error object if an error occurred, or null otherwise. While the second parameter will contain the index information or null if an error occurred. |
---|---|
Returns: | null |
An example of a simple single server db connection
var Db = require('mongodb').Db, MongoClient = require('mongodb').MongoClient, Server = require('mongodb').Server, ReplSetServers = require('mongodb').ReplSetServers, ObjectID = require('mongodb').ObjectID, Binary = require('mongodb').Binary, GridStore = require('mongodb').GridStore, Grid = require('mongodb').Grid, Code = require('mongodb').Code, BSON = require('mongodb').pure().BSON, assert = require('assert'); var db = new Db('test', new Server('localhost', 27017)); // Establish connection to db db.open(function(err, db) { assert.equal(null, err); db.on('close', test.done.bind(test)); db.close(); });
相关文章推荐
- MongoDB Node.js driver
- MongoDB Native Node.js Driver
- 使用Node.js + MongoDB实现一个简单的日志分析系统
- 使用html5+nodejs+mongodb+redis进行web游戏开发(一)准备工作
- nodejs+mongodb实现curd 登录 注销 分页等功能的实现过程
- nodejs + express + ejs + mongodb 一个非常简单的前后端开发的实例2
- nodejs + express + ejs + mongodb 一个非常简单的前后端开发的实例
- A Node.js and MongoDB Powered Twitter Clone
- 从零开始node.js入门项目(四)数据对象(mongodb)
- nodejs mongodb 多字段排序
- node.js 学习笔记五:连接mongodb
- 全方位的NodeJS+mongodb开发环境搭建
- 使用Node.js + Mongodb构建基于Cloud Foundry的项目
- node.js中连接mongodb(Please ensure that you set the default write...)解决办法
- node.js结合mongodb
- Nodejs + mongoDB 使用初体验
- node.js结合mongodb
- CUBRID Node.js Driver 1.1 发布
- Node.JS平台上的数据库Redis,MongoDB,HBASE,MySQL
- node.js对mongodb的一些操作