@@ -37,6 +37,32 @@ operations with examples.
3737 * - Operation
3838 - Example
3939
40+ * - ``Model#attributes``
41+
42+ *Returns a hash of the document's attributes with its values in
43+ mongoized form (i.e. the way they are stored in the db).*
44+
45+ *In Mongoid 8.0 by default, and Mongoid 7.5 with the*
46+ ``legacy_attributes`` *flag set to false, the object returned from this
47+ method will have class* ``Hash``, *and have string keys. In Mongoid 7.5
48+ by default, and in Mongoid 8.0 with the* ``legacy_attributes`` *flag set
49+ to true, the object returned from this method will be a*
50+ ``BSON::Document`` *(and thus, indifferently accessible) if the document
51+ has been retrieved from the database, and a* ``Hash`` *with string keys
52+ if it is a new document.*
53+
54+ *The attributes hash also contains the attributes of all embedded
55+ documents, as well as their embedded documents, etc. If an embedded
56+ association is empty, its key will not show up in the returned hash.*
57+
58+ -
59+ .. code-block:: ruby
60+
61+ person = Person.new(first_name: "Heinrich", last_name: "Heine")
62+
63+ person.attributes
64+ # => { "_id" => BSON::ObjectId('633467d03282a43784c2d56e'), "first_name" => "Heinrich", "last_name" => "Heine" }
65+
4066 * - ``Model.create!``
4167
4268 *Insert a document or multiple documents into the database, raising an
0 commit comments