1. Mongoose

node.js mongodb 库

1.1. Built-in Promises

mongoose 默认返回的是 mpromise, mongoose推荐使用原生的 global.Promise 或者第三方的promise,例如: require('bluebird')

1.2. 自定义 _id

var Post = new mongoose.Schema({
    _id: Number,
    title: String,
    content: String,
    tags: [ String ]
});

OR

var Post = new mongoose.Schema({
    title: String,
    content: String,
    tags: [ String ]
}, { _id: false });

1.3. array to json

lean()

Collection.find().lean();

results matching ""

    No results matching ""