Skip to content

Commit e0d3de9

Browse files
authored
MONGOID-4834 Capped collection documentation examples lack setup/context (#5337)
1 parent 4674f42 commit e0d3de9

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

docs/reference/collection-configuration.txt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,20 @@ Mongoid does not provide a mechanism for creating capped collections on the fly
1818
will need to create these yourself one time up front either with the driver or via the
1919
Mongo console.
2020

21-
To create a capped collection with the driver:
21+
To create a capped collection with the driver, first retrieve the client:
2222

2323
.. code-block:: ruby
2424

25-
client["name", :capped => true, :size => 1024].create
25+
class Name
26+
include Mongoid::Document
27+
end
28+
client = Name.collection.client
29+
30+
Then create the collection:
31+
32+
.. code-block:: ruby
33+
34+
client["names", :capped => true, :size => 1024].create
2635

2736
To create a capped collection from the Mongo console:
2837

0 commit comments

Comments
 (0)