ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Mongoose介绍

Mongoose介绍

原创 Linux操作系统 作者:jieforest 时间:2012-08-06 13:04:40 0 删除 编辑

What's Mongoose?
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

Defining a model is as easy as:

CODE:

var Comment = new Schema({
    title     : String
  , body      : String
  , date      : Date
});

var BlogPost = new Schema({
    author    : ObjectId
  , title     : String
  , body      : String
  , buf       : Buffer
  , date      : Date
  , comments  : [Comment]
  , meta      : {
      votes : Number
    , favs  : Number
  }
});

var Post = mongoose.model('BlogPost', BlogPost);

Installation

The recommended way is through the excellent NPM:
$ npm install mongoose

Otherwise, you can check it in your repository and then expose it:
$ git clone git://github.com/LearnBoost/mongoose.git node_modules/mongoose/

And install dependency modules written on package.json.

Then you can require it:
require('mongoose')

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/301743/viewspace-739939/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: Python输出日志
请登录后发表评论 登录
全部评论

注册时间:2008-04-23

  • 博文量
    441
  • 访问量
    602347