Mongoose v4.5.10發布,讓node.js更優雅的操作MongoDB

jopen 8年前發布 | 9K 次閱讀 MongoDB ROM Node.js mongoose

Mongoose是MongoDB的一個對象模型工具,既類似ORM,讓node.js操作MongoDB更加方便。

官方例子:

// 引入 mongoose 這個模塊

var mongoose = require('mongoose');

// 連接對應的數據庫:mongodb://localhost/test

mongoose.connect('mongodb://localhost/test');

// 創建了一個名為 Cat 的 model,mongoose 會將名詞變為復數,在這里,collection 的名字會是 `cats`。

// model定義: 有一個 String 類型的 name

var Cat = mongoose.model('Cat', {name: String});

var kitty = new Cat({ name: 'Zildjian'});

// 調用 .save 方法后,mongoose 會去你的 mongodb 中的 test 數據庫里,存入一條記錄。

kitty.save(function (err) {

  if (err) {

    console.log(err);

  } else {

    console.log('meow');

  }

});

更新日志

  • docs: fix typo on documents.jade #4444 Gabri3l
  • chore: upgrade mocha to 3.0.2 #4437 TrejGun
  • fix: subdocuments causing error with parent timestamp on update #4434 dyang108
  • fix(query): don't crash if timestamps on and update doesn't have a path #4425 #4424 #4418
  • fix(query): ensure single nested subdoc is hydrated when running update validators #4420
  • fix(query): cast non-$geometry operators for $geoWithin #4419
  • docs: update contributor count #4415 AdamZaczek
  • docs: add more clarification re: the index event #4410
  • fix(document): only skip modifying subdoc path if parent is direct modified #4405
  • fix(schema): throw cast error if provided date invalid #4404
  • feat(error): use util.inspect() so CastError never prints "[object Object]" #4398
  • fix(model): dont error if the discriminator key is unchanged #4387
  • fix(query): don't throw unhandled rejection with bluebird when using cbs #4379

下載

本站原創,轉載時保留以下信息:
本文轉自:深度開源(open-open.com)
原文地址:http://www.baiduhome.net/news/view/7dde7e41

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!