File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed
Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,8 @@ toc_landing_pages = [
1010 " /quick-start-rails" ,
1111 " /quick-start-sinatra" ,
1212 " /interact-data" ,
13- " /interact-data/specify-query"
13+ " /interact-data/specify-query" ,
14+ " /data-modeling"
1415 ]
1516
1617[constants ]
Original file line number Diff line number Diff line change @@ -53,6 +53,39 @@ similar to a {+language+} hash or JSON object. You can store instances
5353of your models directly in a collection in the database, or you can
5454embed them in other classes that use the ``Document`` module.
5555
56+ The following code creates an instance of the ``Person`` model defined
57+ in the preceding section:
58+
59+ .. code-block:: ruby
60+
61+ Person.create(name: 'Meena Kumar')
62+
63+ The document appears in MongoDB as follows:
64+
65+ .. code-block:: json
66+
67+ {
68+ "_id": {
69+ "$oid": "673b6dce61700598c24a72b0"
70+ },
71+ "name": "Meena Kumar"
72+ }
73+
74+ .. note:: _id Field
75+
76+ When you persist an instance of a model to the database, MongoDB
77+ automatically adds an ``_id`` field that has a unique value even if you
78+ do not explicitly define this field in your model.
79+
80+ To learn more about this field, see the :manual:`ObjectId reference
81+ </reference/bson-types/#objectid>` in the {+server-manual+}.
82+
83+ Additional Information
84+ ----------------------
85+
86+ To learn how to access and change your MongoDB data, see the
87+ :ref:`mongoid-interact-data` guides.
88+
5689To learn more about how to model your data by using {+odm+} models,
5790see the :ref:`mongoid-data-modeling` guides.
5891
You can’t perform that action at this time.
0 commit comments