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

jopen 8年前
   <p style="text-align: center;"><img alt="" src="https://simg.open-open.com/show/8b6dbbafd94e5f9bf087b7a0b31ef2d4.jpg" /></p>    <p> </p>    <p>详细:</p>    <p>Mongoose是MongoDB的一个对象模型工具,既类似ORM,让node.js操作MongoDB更加方便。</p>    <p>官方例子:</p>    <p>// 引入 mongoose 这个模块</p>    <p>var mongoose = require('mongoose');</p>    <p>// 连接对应的数据库:mongodb://localhost/test</p>    <p>mongoose.connect('mongodb://localhost/test');</p>    <p>// 创建了一个名为 Cat 的 model,mongoose 会将名词变为复数,在这里,collection 的名字会是 `cats`。</p>    <p>// model定义: 有一个 String 类型的 name</p>    <p>var Cat = mongoose.model('Cat', {name: String});</p>    <p>var kitty = new Cat({ name: 'Zildjian'});</p>    <p>// 调用 .save 方法后,mongoose 会去你的 mongodb 中的 test 数据库里,存入一条记录。</p>    <p>kitty.save(function (err) {</p>    <p>  if (err) {</p>    <p>    console.log(err);</p>    <p>  } else {</p>    <p>    console.log('meow');</p>    <p>  }</p>    <p>});</p>    <p> </p>    <h2>更新日志</h2>    <ul>     <li>fix(query): improve handling of $not with $elemMatch #4531 #3719 <a href="/misc/goto?guid=4958993911407968584">timbowhite</a></li>     <li>fix: upgrade mongodb -> 2.2.10 #4517</li>     <li>chore: fix webpack build issue #4512 <a href="/misc/goto?guid=4958993911543622732">saiichihashimoto</a></li>     <li>fix(query): emit error on next tick when exec callback errors #4500</li>     <li>test: improve test case #4496 <a href="/misc/goto?guid=4958993911674187939">isayme</a></li>     <li>fix(schema): use same check for array types and top-level types #4493</li>     <li>style: fix indentation in docs #4489 <a href="/misc/goto?guid=4958993911821669482">dhurlburtusa</a></li>     <li>fix(schema): expose original object passed to constructor #4486</li>     <li>fix(query): handle findOneAndUpdate with array of arrays #4484 #4470 <a href="/misc/goto?guid=4958993911953521198">fedotov</a></li>     <li>feat(document): add $ignore to make a path ignored #4480</li>     <li>fix(query): properly handle setting single embedded in update #4475 #4466 #4465</li>     <li>fix(updateValidators): handle single nested schema subpaths correctly #4479</li>     <li>fix(model): throw handy error when method name conflicts with property name #4475</li>     <li>fix(schema): handle .set() with array field #4472</li>     <li>fix(query): check nested path when avoiding double-validating Mixed #4441</li>     <li>fix(schema): handle calling path.trim() with no args correctly #4042</li>    </ul>    <p> </p>    <h2>下载</h2>    <ul>     <li><a href="/misc/goto?guid=4958993912085177988" rel="nofollow"><strong>Source code</strong> (zip)</a></li>     <li><a href="/misc/goto?guid=4958993912219787641" rel="nofollow"><strong>Source code</strong> (tar.gz)</a></li>    </ul>    <p> </p>    <p>本站原创,转载时保留以下信息:<br /> 本文转自:深度开源(open-open.com)<br /> 原文地址:<a href="http://www.open-open.com/news/view/bc58211">http://www.open-open.com/news/view/bc58211</a></p>