<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[MongoDB study notes - Medium]]></title>
        <description><![CDATA[Learning MongoDB now ! - Medium]]></description>
        <link>https://medium.com/mongodb-study-notes?source=rss----43c4fa0f20bf---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>MongoDB study notes - Medium</title>
            <link>https://medium.com/mongodb-study-notes?source=rss----43c4fa0f20bf---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 06:37:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/mongodb-study-notes" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[MongoDB]]></title>
            <link>https://medium.com/mongodb-study-notes/mongodb-ed9198b36ffc?source=rss----43c4fa0f20bf---4</link>
            <guid isPermaLink="false">https://medium.com/p/ed9198b36ffc</guid>
            <dc:creator><![CDATA[WhySoSilent?]]></dc:creator>
            <pubDate>Sat, 21 Dec 2013 10:01:55 GMT</pubDate>
            <atom:updated>2013-12-21T10:01:51.416Z</atom:updated>
            <content:encoded><![CDATA[<h4>更新 </h4><h4>区别更新与查询操作符的语法</h4><p>基本上，更新操作符是<strong>前缀</strong>，查询操作符通常是<strong>中缀</strong></p><blockquote>collection.update({ price: {$lte: 10 }}, { $addToSet : { tags: ‘cheap’ }})</blockquote><h4>多文档更新</h4><p>默认更新操作只更新匹配到的第一个文档，否则添加 {multi: true}</p><h4>upsert</h4><p>不存在时则插入，存在时更新 添加{upsert: true}</p><p>$inc</p><h4>更新、原子操作、删除</h4><blockquote>updata({},{‘$set’ : {email: ‘new address’}})<br>updata({},{‘$push’: {‘arrayName’: {…}}})</blockquote><h4>索引</h4><p>为文档建立一个唯一性索性可用于做短名称主键</p><blockquote>db.collection.ensure({slug,1},{unique:true})</blockquote><p>有唯一性索引的插入操作使用安全模式方能确认插入是否成功，因为可能造成不唯一插入冲突</p><h4>查询选择器</h4><blockquote>&lt; &lt;= &gt; &gt;=</blockquote><p>$lt $lte $gt $gte</p><p>范围选择器涉及到了类型！注意类型不同时的差异</p><h3>集合操作符</h3><blockquote>{‘product.color’ : { $nin : [‘black’,’blue’] }</blockquote><p>$in 类似于或运算</p><p>$nin 与给定元素都不匹配时才返回该文档</p><p>$all 与给定的每个元素都匹配时返回文档，如在数组匹配当中</p><p>牢记 $in 和 $all 都能利用索引，但 $nin 不能 ！</p><h4>布尔操作符</h4><p>$ne 不等于</p><p>$ne 无法利用索引，实践中最好和其他操作符结合使用否则查询效率可能不高</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed9198b36ffc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/mongodb-study-notes/mongodb-ed9198b36ffc">MongoDB</a> was originally published in <a href="https://medium.com/mongodb-study-notes">MongoDB study notes</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>