Skip to content

Commit

Permalink
Update changes from mm update
Browse files Browse the repository at this point in the history
  • Loading branch information
durran committed Jul 10, 2012
1 parent 957d5a2 commit 39e9287
Show file tree
Hide file tree
Showing 31 changed files with 8,809 additions and 8,809 deletions.
248 changes: 124 additions & 124 deletions en/mongoid/docs/callbacks.html

Large diffs are not rendered by default.

266 changes: 133 additions & 133 deletions en/mongoid/docs/contributing.html

Large diffs are not rendered by default.

1,048 changes: 524 additions & 524 deletions en/mongoid/docs/documents.html

Large diffs are not rendered by default.

218 changes: 109 additions & 109 deletions en/mongoid/docs/extras.html
Expand Up @@ -4,15 +4,15 @@
<meta content='A Ruby ODM for MongoDB' name='description' />
<meta content='mongoid, mongodb, ruby, rails, odm, durran jordan' name='keywords' />
<link href="/stylesheets/bootstrap.min.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/mongoid.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/mongoid-coderay.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/bootstrap-responsive.min.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/javascripts/jquery-1.7.2.js" type="text/javascript"></script>
<script src="/javascripts/bootstrap-dropdown.js" type="text/javascript"></script>
<script src="/javascripts/bootstrap-scrollspy.js" type="text/javascript"></script>
<script src="/javascripts/bootstrap-tooltip.js" type="text/javascript"></script>
<script src="/javascripts/mongoid.js" type="text/javascript"></script>
<title>Mongoid: Extras</title>
<link href="/stylesheets/mongoid.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/mongoid-coderay.css" media="screen" rel="stylesheet" type="text/css" />
<link href="/stylesheets/bootstrap-responsive.min.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/javascripts/jquery-1.7.2.js" type="text/javascript"></script>
<script src="/javascripts/bootstrap-dropdown.js" type="text/javascript"></script>
<script src="/javascripts/bootstrap-scrollspy.js" type="text/javascript"></script>
<script src="/javascripts/bootstrap-tooltip.js" type="text/javascript"></script>
<script src="/javascripts/mongoid.js" type="text/javascript"></script>
<title>Mongoid: Extras</title>
</head>
<body data-offset='100' data-spy='scroll' data-target='.page-nav'>
<div class='mongoid' id='header'>
Expand Down Expand Up @@ -80,106 +80,106 @@
<div id='content'>
<div class='container'>
<h1>Extras</h1>
<p>
Mongoid has some useful extra features that can be used in applications.
</p>
<div class='page-nav'>
<div class='container'>
<ul class='nav nav-pills'>
<li><a href="#caching">Caching</a></li>
<li><a href="#paranoia">Paranoia</a></li>
<li><a href="#versioning">Versioning</a></li>
<li><a href="#timestamps">Timestamping</a></li>
</ul>
</div>
</div>
<section id='caching'>
<h2>Caching</h2>
<p>
Out of the box, Mongoid wraps the MongoDB Ruby Driver's cursor in order
to be memory efficient for large queries and data sets. However if you
want the query to load all matching documents in memory and return
them on <i>n</i> iterations without hitting the database again you
may cache a criteria:
</p>
<p>
To cache on a per-query basis:
</p>
<div class="CodeRay">
<div class="code"><pre><span class="constant">Person</span>.where(first_name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Franziska</span><span class="delimiter">&quot;</span></span>).cache&#x000A;</pre></div>
</div>
</section>
<section id='paranoia'>
<h2>Paranoid Documents</h2>
<p>
There may be times when you don't want documents to actually get deleted
from the database, but "flagged" as deleted. Mongoid provides a Paranoia
module to give you just that.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Paranoia</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;person.delete <span class="comment"># Sets the deleted_at field to the current time.</span>&#x000A;person.delete! <span class="comment"># Permanently deletes the document.</span>&#x000A;person.destroy! <span class="comment"># Permanently delete the document with callbacks.</span>&#x000A;person.restore <span class="comment"># Brings the &quot;deleted&quot; document back to life.</span>&#x000A;</pre></div>
</div>
<p>
The documents that have been "flagged" as deleted (soft deleted)
can be accessed at any time by calling the <code>deleted</code>
class method on the class.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="constant">Person</span>.deleted <span class="comment"># Returns documents that have been &quot;flagged&quot; as deleted.</span>&#x000A;</pre></div>
</div>
</section>
<section id='versioning'>
<h2>Versioning</h2>
<p>
Mongoid supports simple versioning through inclusion of the
<code>Mongoid::Versioning</code> module. Including this module will create a
versions embedded relation on the document that it will append to on
each save. It will also update the version number on the document,
which is an integer.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Versioning</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
You can also set a <code>max_versions</code> setting, and Mongoid will only
keep the max most recent versions.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Versioning</span>&#x000A;&#x000A; <span class="comment"># keep at most 5 versions of a record</span>&#x000A; max_versions <span class="integer">5</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
You may skip versioning at any point in time by wrapping the persistence
call in a <code>versionless</code> block.
</p>
<div class="CodeRay">
<div class="code"><pre>person.versionless <span class="keyword">do</span> |doc|&#x000A; doc.update_attributes(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Theodore</span><span class="delimiter">&quot;</span></span>)&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
</section>
<section id='timestamps'>
<h2>Timestamping</h2>
<p>
Mongoid supplies a timestamping module in <code>Mongoid::Timestamps</code> which
can be included to get basic behavior for <code>created_at</code> and
<code>updated_at</code> fields.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Timestamps</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
You may also choose to only have specific timestamps for creation or
modification.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Timestamps</span>::<span class="constant">Created</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;<span class="keyword">class</span> <span class="class">Post</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Timestamps</span>::<span class="constant">Updated</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
If you want to turn off timestamping for specific calls, use the timeless
method:
</p>
<div class="CodeRay">
<div class="code"><pre>person.timeless.save&#x000A;<span class="constant">Person</span>.timeless.create!</pre></div>
</div>
</section>
<p>
Mongoid has some useful extra features that can be used in applications.
</p>
<div class='page-nav'>
<div class='container'>
<ul class='nav nav-pills'>
<li><a href="#caching">Caching</a></li>
<li><a href="#paranoia">Paranoia</a></li>
<li><a href="#versioning">Versioning</a></li>
<li><a href="#timestamps">Timestamping</a></li>
</ul>
</div>
</div>
<section id='caching'>
<h2>Caching</h2>
<p>
Out of the box, Mongoid wraps the MongoDB Ruby Driver's cursor in order
to be memory efficient for large queries and data sets. However if you
want the query to load all matching documents in memory and return
them on <i>n</i> iterations without hitting the database again you
may cache a criteria:
</p>
<p>
To cache on a per-query basis:
</p>
<div class="CodeRay">
<div class="code"><pre><span class="constant">Person</span>.where(first_name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Franziska</span><span class="delimiter">&quot;</span></span>).cache&#x000A;</pre></div>
</div>
</section>
<section id='paranoia'>
<h2>Paranoid Documents</h2>
<p>
There may be times when you don't want documents to actually get deleted
from the database, but "flagged" as deleted. Mongoid provides a Paranoia
module to give you just that.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Paranoia</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;person.delete <span class="comment"># Sets the deleted_at field to the current time.</span>&#x000A;person.delete! <span class="comment"># Permanently deletes the document.</span>&#x000A;person.destroy! <span class="comment"># Permanently delete the document with callbacks.</span>&#x000A;person.restore <span class="comment"># Brings the &quot;deleted&quot; document back to life.</span>&#x000A;</pre></div>
</div>
<p>
The documents that have been "flagged" as deleted (soft deleted)
can be accessed at any time by calling the <code>deleted</code>
class method on the class.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="constant">Person</span>.deleted <span class="comment"># Returns documents that have been &quot;flagged&quot; as deleted.</span>&#x000A;</pre></div>
</div>
</section>
<section id='versioning'>
<h2>Versioning</h2>
<p>
Mongoid supports simple versioning through inclusion of the
<code>Mongoid::Versioning</code> module. Including this module will create a
versions embedded relation on the document that it will append to on
each save. It will also update the version number on the document,
which is an integer.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Versioning</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
You can also set a <code>max_versions</code> setting, and Mongoid will only
keep the max most recent versions.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Versioning</span>&#x000A;&#x000A; <span class="comment"># keep at most 5 versions of a record</span>&#x000A; max_versions <span class="integer">5</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
You may skip versioning at any point in time by wrapping the persistence
call in a <code>versionless</code> block.
</p>
<div class="CodeRay">
<div class="code"><pre>person.versionless <span class="keyword">do</span> |doc|&#x000A; doc.update_attributes(name: <span class="string"><span class="delimiter">&quot;</span><span class="content">Theodore</span><span class="delimiter">&quot;</span></span>)&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
</section>
<section id='timestamps'>
<h2>Timestamping</h2>
<p>
Mongoid supplies a timestamping module in <code>Mongoid::Timestamps</code> which
can be included to get basic behavior for <code>created_at</code> and
<code>updated_at</code> fields.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Timestamps</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
You may also choose to only have specific timestamps for creation or
modification.
</p>
<div class="CodeRay">
<div class="code"><pre><span class="keyword">class</span> <span class="class">Person</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Timestamps</span>::<span class="constant">Created</span>&#x000A;<span class="keyword">end</span>&#x000A;&#x000A;<span class="keyword">class</span> <span class="class">Post</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Document</span>&#x000A; include <span class="constant">Mongoid</span>::<span class="constant">Timestamps</span>::<span class="constant">Updated</span>&#x000A;<span class="keyword">end</span>&#x000A;</pre></div>
</div>
<p>
If you want to turn off timestamping for specific calls, use the timeless
method:
</p>
<div class="CodeRay">
<div class="code"><pre>person.timeless.save&#x000A;<span class="constant">Person</span>.timeless.create!</pre></div>
</div>
</section>
</div>
</div>
</body>
Expand Down

0 comments on commit 39e9287

Please sign in to comment.