Mongoose v4.5.6 发布,让node.js更优雅的操作MongoDB

jopen 8年前
   <p style="text-align: center;"><img alt="" src="https://simg.open-open.com/show/8b6dbbafd94e5f9bf087b7a0b31ef2d4.jpg" /></p>    <p>Mongoose是MongoDB的一个对象模型工具,既类似ORM,让node.js操作MongoDB更加方便。</p>    <p>官方例子:</p>    <pre>  <code class="language-actionscript">// 引入 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');    }  });  </code></pre>    <h2>更新日志</h2>    <ul>     <li>fix(schema): don't overwrite createdAt if it isn't selected #4351 <a href="/misc/goto?guid=4958971344828622364">tusbar</a></li>     <li>docs(api): fix link to populate() and add a new one from depopulate() #4345 <a href="/misc/goto?guid=4958992423533411077">Delapouite</a></li>     <li>fix(types): ownerDocument() works properly with single nested docs #4344 <a href="/misc/goto?guid=4958992423669189942">vichle</a></li>     <li>fix(populate): dont use findOne when justOne option set #4329</li>     <li>fix(document): dont trigger .then() deprecated warning when calling doc.remove() #4291</li>     <li>docs(connection): add promiseLibrary option #4280</li>     <li>fix(plugins): apply global plugins to subschemas #4271</li>     <li>fix(model): ensure <code>ensureIndex()</code> never calls back in the same tick #4246</li>     <li>docs(schema): improve post hook docs on schema #4238</li>    </ul>    <h2>下载</h2>    <ul>     <li><a href="/misc/goto?guid=4958992423785744889" rel="nofollow"><strong>Source code</strong> (zip)</a></li>     <li><a href="/misc/goto?guid=4958992423924157731" rel="nofollow"><strong>Source code</strong> (tar.gz)</a></li>    </ul>