@@ -30,4 +30,152 @@ Write Data to MongoDB
3030 /write/transactions
3131 /write/gridfs
3232
33- .. TODO
33+ Overview
34+ --------
35+
36+ On this page, you can see copyable code examples that show common methods you
37+ can use to write data to MongoDB by using the {+driver-short+}.
38+
39+ .. tip::
40+
41+ To learn more about any of the methods shown on this page, see the link
42+ provided in each section.
43+
44+ To use an example from this page, copy the code example into the :ref:`sample
45+ application <ruby-write-sample>` or your own application. Be sure to replace all
46+ placeholders in the code examples, such as ``<connection string>``, with the
47+ relevant values for your MongoDB deployment.
48+
49+ .. _ruby-write-sample:
50+
51+ .. include:: /includes/usage-examples/sample-app-intro.rst
52+
53+ .. literalinclude:: /includes/usage-examples/sample-app.rb
54+ :language: ruby
55+ :copyable:
56+ :linenos:
57+ :emphasize-lines: 13-15
58+
59+ Insert One
60+ ----------
61+
62+ The following code shows how to insert a single document into a collection:
63+
64+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
65+ :start-after: start-insert-one
66+ :end-before: end-insert-one
67+ :language: ruby
68+ :copyable:
69+ :dedent:
70+
71+ To learn more about the ``insert_one`` method, see the
72+ :ref:`Insert Documents <ruby-write-insert>` guide.
73+
74+ Insert Multiple
75+ ---------------
76+
77+ The following code shows how to insert multiple documents into a collection:
78+
79+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
80+ :start-after: start-insert-many
81+ :end-before: end-insert-many
82+ :language: ruby
83+ :copyable:
84+ :dedent:
85+
86+ To learn more about the ``insert_many`` method, see the
87+ :ref:`Insert Documents <ruby-write-insert>` guide.
88+
89+ Update One
90+ ----------
91+
92+ The following code shows how to update a single document in a collection by
93+ creating or editing a field:
94+
95+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
96+ :start-after: start-update-one
97+ :end-before: end-update-one
98+ :language: ruby
99+ :copyable:
100+ :dedent:
101+
102+ To learn more about the ``update_one`` method, see the
103+ :ref:`ruby-write-update` guide.
104+
105+ Update Multiple
106+ ---------------
107+
108+ The following code shows how to update multiple documents in a collection by
109+ creating or editing a field:
110+
111+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
112+ :start-after: start-update-many
113+ :end-before: end-update-many
114+ :language: ruby
115+ :copyable:
116+ :dedent:
117+
118+ To learn more about the ``update_many`` method, see the
119+ :ref:`ruby-write-update` guide.
120+
121+ Replace One
122+ -----------
123+
124+ The following code shows how to replace a single document in a collection with a new
125+ document:
126+
127+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
128+ :start-after: start-replace-one
129+ :end-before: end-replace-one
130+ :language: ruby
131+ :copyable:
132+ :dedent:
133+
134+ To learn more about the ``replace_one`` method, see the
135+ :ref:`Replace Documents <ruby-write-replace>` guide.
136+
137+ Delete One
138+ ----------
139+
140+ The following code shows how to delete a single document in a collection:
141+
142+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
143+ :start-after: start-delete-one
144+ :end-before: end-delete-one
145+ :language: ruby
146+ :copyable:
147+ :dedent:
148+
149+ To learn more about the ``delete_one`` method, see the
150+ :ref:`Delete Documents <ruby-write-delete>` guide.
151+
152+ Delete Multiple
153+ ---------------
154+
155+ The following code shows how to delete multiple documents in a collection:
156+
157+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
158+ :start-after: start-delete-many
159+ :end-before: end-delete-many
160+ :language: ruby
161+ :copyable:
162+ :dedent:
163+
164+ To learn more about the ``delete_many`` method, see the
165+ :ref:`Delete Documents <ruby-write-delete>` guide.
166+
167+ Bulk Write
168+ ----------
169+
170+ The following code shows how to perform multiple write operations in a single
171+ bulk operation:
172+
173+ .. literalinclude:: /includes/usage-examples/write-code-examples.rb
174+ :start-after: start-bulk-write
175+ :end-before: end-bulk-write
176+ :language: ruby
177+ :copyable:
178+ :dedent:
179+
180+ To learn more about the ``bulk_write``
181+ method, see the :ref:`Bulk Write Operations <ruby-bulk-write>` guide.
0 commit comments