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

jopen 8年前發布 | 11K 次閱讀 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: add mixed schema doc for Object literal #4400 Kikobeats
  • fix(query): cast $geoWithin and convert mongoose objects to POJOs before casting #4392
  • fix(schematype): dont cast defaults without parent doc #4390
  • fix(query): disallow passing empty string to findOne() #4378
  • fix(document): set single nested doc isNew correctly #4369
  • fix(types): checks field name correctly with nested arrays and populate #4365
  • fix(drivers): make debug output copy-pastable into mongodb shell #4352
  • fix(services): run update validators on nested paths #4332
  • fix(model): handle typeKey with discriminators #4339
  • fix(query): apply timestamps to child schemas when explicitly specified in update #4049
  • fix(schema): set prefix as nested path with add() #1730

下載

 

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

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