-
Notifications
You must be signed in to change notification settings - Fork 29
DOCSP-42743 Collection config #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,104 @@ | ||||||||||||||
.. _mongoid-collection-config: | ||||||||||||||
|
||||||||||||||
======================== | ||||||||||||||
Collection Configuration | ||||||||||||||
======================== | ||||||||||||||
|
||||||||||||||
.. facet:: | ||||||||||||||
:name: genre | ||||||||||||||
:values: reference | ||||||||||||||
|
||||||||||||||
.. meta:: | ||||||||||||||
:keywords: code example, collections, time series, capped collection | ||||||||||||||
|
||||||||||||||
.. contents:: On this page | ||||||||||||||
:local: | ||||||||||||||
:backlinks: none | ||||||||||||||
:depth: 2 | ||||||||||||||
:class: singlecol | ||||||||||||||
|
||||||||||||||
Overview | ||||||||||||||
-------- | ||||||||||||||
|
||||||||||||||
In this guide, you can learn how to specify configuration options for a | ||||||||||||||
collection in your {+odm+} application. | ||||||||||||||
|
||||||||||||||
Configure Collection Options | ||||||||||||||
---------------------------- | ||||||||||||||
|
||||||||||||||
You can specify configuration options for a collection by using the | ||||||||||||||
``:collection_options`` argument with the ``store_in`` | ||||||||||||||
macro. The ``:collection_options`` argument accepts any collection option that | ||||||||||||||
your driver and server version supports. | ||||||||||||||
|
your driver and server version supports. | |
your {+ruby-driver+} and MongoDB server version supports. |
Check failure on line 37 in source/configuration/collection-config.txt
GitHub Actions / TDBX Vale rules
[vale] reported by reviewdog 🐶
[MongoDB.Wordiness] Consider using 'before' instead of 'prior to'.
Raw Output:
{"message": "[MongoDB.Wordiness] Consider using 'before' instead of 'prior to'.", "location": {"path": "source/configuration/collection-config.txt", "range": {"start": {"line": 37, "column": 4}}}, "severity": "ERROR"}
Check failure on line 37 in source/configuration/collection-config.txt
GitHub Actions / TDBX Vale rules
[vale] reported by reviewdog 🐶
[MongoDB.ConciseTerms] 'before' is preferred over 'prior to'.
Raw Output:
{"message": "[MongoDB.ConciseTerms] 'before' is preferred over 'prior to'.", "location": {"path": "source/configuration/collection-config.txt", "range": {"start": {"line": 37, "column": 4}}}, "severity": "ERROR"}
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To apply the collection options, your collection must be explicitly created | |
prior to use. To learn how to create a collection using a Rake task, see the | |
You must explicitly create a collection before you apply any collection options. To learn | |
how to create a collection by using a Rake task, see the |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: consider linking to docs in server or atlas about creating collections.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ended up rewording this section to better match what the original docs were saying. It says that it "should be done" by the Rake task so it seems to me like they want to point users that way rather than other ways of creating collection
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following sections show examples of how to configure collection options with | |
{+odm+}. | |
The following sections show examples of how to configure collection options when using | |
{+odm+}. |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
collection with | |
{+odm+}: | |
collection: |
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: could be helpful to describe what the options in the code are doing. Or you can link out to docs on time series collections or both ideally
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I linked out to the manual for descriptions since the functionality of the collection isn't the focus of this page
rustagir marked this conversation as resolved.
Show resolved
Hide resolved
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Capped collections have maximum size or document counts that prevent them from | |
growing beyond maximum thresholds. The following example shows how to configure | |
a capped collection with {+odm+}: | |
Capped collections have maximum size or document counts that prevent them from | |
growing beyond a specified threshold. The following example shows how to configure | |
a capped collection: |
rustagir marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: same comment about explaining + linking
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# start-time-series-config | ||
class Measurement | ||
include Mongoid::Document | ||
|
||
field :temperature, type: Integer | ||
field :timestamp, type: Time | ||
|
||
store_in collection_options: { | ||
time_series: { | ||
timeField: "timestamp", | ||
granularity: "minutes" | ||
}, | ||
expire_after: 604800 | ||
} | ||
end | ||
# end-time-series-config | ||
|
||
# start-capped-collection-config | ||
class Name | ||
include Mongoid::Document | ||
|
||
store_in collection_options: { | ||
capped: true, | ||
size: 1024 | ||
} | ||
end | ||
# end-capped-collection-config | ||
|
||
# start-default-collation-config | ||
class Name | ||
include Mongoid::Document | ||
|
||
store_in collection_options: { | ||
collation: { | ||
locale: 'fr' | ||
} | ||
} | ||
end | ||
# end-default-collation-config | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. S: consider renaming these models as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.