Permalink
Browse files

Update origin docs. [ fix #4 ]

  • Loading branch information...
1 parent 0c782a8 commit 29a1435783a1fc232db99a9fbfbed56157d1e3bc @durran durran committed Dec 25, 2012
Showing with 6 additions and 6 deletions.
  1. +1 −1 en/mongoid/docs/tips.html
  2. +3 −3 en/origin/docs/installation.html
  3. +1 −1 en/origin/docs/options.html
  4. +1 −1 en/origin/index.html
@@ -274,7 +274,7 @@
of accessing an Active Record model from Mongoid manually.
</p>
<div class="CodeRay">
- <div class="code"><pre><span class="keyword">class</span> <span class="class">Band</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A;&#x000A; field <span class="symbol">:user_id</span>, type: <span class="constant">Integer</span>&#x000A;&#x000A; <span class="keyword">def</span> <span class="function">user</span>&#x000A; <span class="instance-variable">@user</span> ||= <span class="constant">Band</span>.where(id: user_id).first&#x000A; <span class="keyword">end</span>&#x000A;&#x000A; <span class="keyword">def</span> <span class="function">user=</span>(user)&#x000A; <span class="predefined-constant">self</span>.user_id = user.id&#x000A; <span class="instance-variable">@user</span> = user&#x000A; <span class="keyword">end</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;<span class="keyword">class</span> <span class="class">User</span> &lt; <span class="constant">ActiveRecord</span>::<span class="constant">Base</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
+ <div class="code"><pre><span class="keyword">class</span> <span class="class">Band</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A;&#x000A; field <span class="symbol">:user_id</span>, type: <span class="constant">Integer</span>&#x000A;&#x000A; <span class="keyword">def</span> <span class="function">user</span>&#x000A; <span class="instance-variable">@user</span> ||= <span class="constant">User</span>.find(user_id)&#x000A; <span class="keyword">end</span>&#x000A;&#x000A; <span class="keyword">def</span> <span class="function">user=</span>(user)&#x000A; <span class="predefined-constant">self</span>.user_id = user.id&#x000A; <span class="instance-variable">@user</span> = user&#x000A; <span class="keyword">end</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;<span class="keyword">class</span> <span class="class">User</span> &lt; <span class="constant">ActiveRecord</span>::<span class="constant">Base</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
</section>
<section id='sidekiq'>
@@ -142,22 +142,22 @@
to query the database for documents.
</p>
<div class="CodeRay">
- <div class="code"><pre>query = <span class="constant">Query</span>.new&#x000A;query.where(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Syd</span><span class="delimiter">&quot;</span></span>).only(<span class="symbol">:name</span>)&#x000A;&#x000A;<span class="comment"># With Moped</span>&#x000A;session[<span class="symbol">:users</span>].find(query.selector).select(query.options.fields)&#x000A;&#x000A;<span class="comment"># With the 10gen driver</span>&#x000A;collection.find(query.selector, query.options)&#x000A;</pre></div>
+ <div class="code"><pre>query = <span class="constant">Query</span>.new.where(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Syd</span><span class="delimiter">&quot;</span></span>).only(<span class="symbol">:name</span>)&#x000A;&#x000A;<span class="comment"># With Moped</span>&#x000A;session[<span class="symbol">:users</span>].find(query.selector).select(query.options.fields)&#x000A;&#x000A;<span class="comment"># With the 10gen driver</span>&#x000A;collection.find(query.selector, query.options)&#x000A;</pre></div>
</div>
<p>
The query's <code>selector</code> is a hash that represents the MongoDB
selector.
</p>
<div class="CodeRay">
- <div class="code"><pre>query = <span class="constant">Query</span>.new&#x000A;query.where(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Syd</span><span class="delimiter">&quot;</span></span>).between(age: <span class="integer">18</span>..<span class="integer">25</span>)&#x000A;query.selector <span class="comment">#=&gt; { &quot;name&quot; =&gt; &quot;Syd&quot;, &quot;age&quot; =&gt; { &quot;$gte&quot; =&gt; 18, &quot;$lte&quot; =&gt; 25 }}</span>&#x000A;</pre></div>
+ <div class="code"><pre>query = <span class="constant">Query</span>.new&#x000A;query = query.where(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Syd</span><span class="delimiter">&quot;</span></span>).between(age: <span class="integer">18</span>..<span class="integer">25</span>)&#x000A;query.selector <span class="comment">#=&gt; { &quot;name&quot; =&gt; &quot;Syd&quot;, &quot;age&quot; =&gt; { &quot;$gte&quot; =&gt; 18, &quot;$lte&quot; =&gt; 25 }}</span>&#x000A;</pre></div>
</div>
<p>
The query's <code>options</code> is a hash that represents various options
that can be passed with a query, such as field limiting, skip, limit, and
sorting options.
</p>
<div class="CodeRay">
- <div class="code"><pre>query = <span class="constant">Query</span>.new&#x000A;query.only(<span class="symbol">:name</span>).skip(<span class="integer">10</span>).limit(<span class="integer">20</span>).desc(<span class="symbol">:name</span>)&#x000A;&#x000A;query.options <span class="comment">#=&gt; { fields: { &quot;name&quot; =&gt; 1 }, skip: 10, limit: 20, sort: { &quot;name&quot; =&gt; -1 }}</span>&#x000A;&#x000A;query.options.fields <span class="comment">#=&gt; { &quot;name&quot; =&gt; 1 }</span>&#x000A;query.options.limit <span class="comment">#=&gt; 20</span>&#x000A;query.options.skip <span class="comment">#=&gt; 10</span>&#x000A;query.options.sort <span class="comment">#=&gt; { &quot;name&quot; =&gt; -1 }</span>&#x000A;</pre></div>
+ <div class="code"><pre>query = <span class="constant">Query</span>.new&#x000A;query = query.only(<span class="symbol">:name</span>).skip(<span class="integer">10</span>).limit(<span class="integer">20</span>).desc(<span class="symbol">:name</span>)&#x000A;&#x000A;query.options <span class="comment">#=&gt; { fields: { &quot;name&quot; =&gt; 1 }, skip: 10, limit: 20, sort: { &quot;name&quot; =&gt; -1 }}</span>&#x000A;&#x000A;query.options.fields <span class="comment">#=&gt; { &quot;name&quot; =&gt; 1 }</span>&#x000A;query.options.limit <span class="comment">#=&gt; 20</span>&#x000A;query.options.skip <span class="comment">#=&gt; 10</span>&#x000A;query.options.sort <span class="comment">#=&gt; { &quot;name&quot; =&gt; -1 }</span>&#x000A;</pre></div>
</div>
</section>
<section id='forwarding'>
@@ -358,7 +358,7 @@
argument to the queryable constructor.
</p>
<div class="CodeRay">
- <div class="code"><pre>queryable = <span class="constant">Query</span>.new({}, {}, <span class="symbol">:mongo</span>)&#x000A;queryable.order_by([[ <span class="symbol">:first_name</span>, <span class="symbol">:desc</span> ], [ <span class="symbol">:last_name</span>, <span class="symbol">:desc</span> ]])&#x000A;queryable.options <span class="comment">#=&gt; { sort: [[ &quot;first_name&quot;, -1 ], [ &quot;last_name&quot;, -1 ]]}</span></pre></div>
+ <div class="code"><pre>queryable = <span class="constant">Query</span>.new({}, {}, <span class="symbol">:mongo</span>)&#x000A;queryable = queryable.order_by([[ <span class="symbol">:first_name</span>, <span class="symbol">:desc</span> ], [ <span class="symbol">:last_name</span>, <span class="symbol">:desc</span> ]])&#x000A;queryable.options <span class="comment">#=&gt; { sort: [[ &quot;first_name&quot;, -1 ], [ &quot;last_name&quot;, -1 ]]}</span></pre></div>
</div>
</section>
</div>
@@ -94,7 +94,7 @@
</table>
</div>
<div class="CodeRay">
- <div class="code"><pre><span class="keyword">class</span> <span class="class">Criteria</span>&#x000A; include <span class="constant">Origin</span>::<span class="constant">Queryable</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;criteria = <span class="constant">Criteria</span>.new&#x000A;criteria.where(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Syd</span><span class="delimiter">&quot;</span></span>).gt(age: <span class="integer">10</span>).desc(<span class="symbol">:created_at</span>)&#x000A;&#x000A;criteria.selector <span class="comment">#=&gt; { name: &quot;Syd&quot;, age: { &quot;$gt&quot; =&gt; 10 }}</span>&#x000A;criteria.options <span class="comment">#=&gt; { sort: { created_at: -1 }}</span></pre></div>
+ <div class="code"><pre><span class="keyword">class</span> <span class="class">Criteria</span>&#x000A; include <span class="constant">Origin</span>::<span class="constant">Queryable</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;criteria = <span class="constant">Criteria</span>.new&#x000A;criteria = criteria.where(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Syd</span><span class="delimiter">&quot;</span></span>).gt(age: <span class="integer">10</span>).desc(<span class="symbol">:created_at</span>)&#x000A;&#x000A;criteria.selector <span class="comment">#=&gt; { name: &quot;Syd&quot;, age: { &quot;$gt&quot; =&gt; 10 }}</span>&#x000A;criteria.options <span class="comment">#=&gt; { sort: { created_at: -1 }}</span></pre></div>
</div>
</div>
</div>

0 comments on commit 29a1435

Please sign in to comment.