|
1 | 1 | .. _java-fundamentals-delete:
|
| 2 | +.. _java-usage-deletemany: |
2 | 3 |
|
3 | 4 | ================
|
4 | 5 | Delete Documents
|
@@ -147,14 +148,54 @@ collection:
|
147 | 148 | { "_id": 1, "color": "red", "qty": 5 }
|
148 | 149 | { "_id": 8, "color": "black", "qty": 8 }
|
149 | 150 |
|
| 151 | +Delete Example File |
| 152 | +------------------- |
| 153 | + |
| 154 | +This code example is a complete, standalone file that performs a delete one |
| 155 | +operation and a delete many operation. It uses the ``movies`` collection in the |
| 156 | +``sample_mflix`` database included in the :atlas:`sample datasets |
| 157 | +</sample-data?jmp=docs_driver_java>` provided by Atlas. You can load them into |
| 158 | +your database on the free tier of MongoDB Atlas by following the :atlas:`Get |
| 159 | +Started with Atlas Guide </getting-started/#atlas-getting-started?jmp=docs_driver_java>` |
| 160 | + |
| 161 | +This example used the ``eq()`` and ``lt()`` filters to query documents. For more |
| 162 | +information about filters, see the `Filters Class |
| 163 | +<{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/Filters.html>`__ |
| 164 | +API documentation. |
| 165 | + |
| 166 | +.. include:: /includes/connect-guide-note.rst |
| 167 | + |
| 168 | +.. io-code-block:: |
| 169 | + |
| 170 | + .. input:: /includes/crud/Delete.java |
| 171 | + :language: java |
| 172 | + :dedent: |
| 173 | + |
| 174 | + .. output:: |
| 175 | + :language: none |
| 176 | + :visible: false |
| 177 | + |
| 178 | + DeleteOne document count: 1 |
| 179 | + DeleteMany document count: 4 |
| 180 | + |
| 181 | +More Information |
| 182 | +---------------- |
| 183 | + |
150 | 184 | For more information about the methods and classes mentioned in this guide,
|
151 | 185 | see the following resources:
|
152 | 186 |
|
153 |
| -- `deleteOne() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#deleteOne(org.bson.conversions.Bson)>`__ API Documentation |
154 |
| -- `deleteMany() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#deleteMany(org.bson.conversions.Bson)>`__ API Documentation |
155 |
| -- `findOneAndDelete() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#findOneAndDelete(org.bson.conversions.Bson)>`__ API Documentation |
156 |
| -- `DeleteOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/DeleteOptions.html>`__ API Documentation |
157 |
| -- `FindOneAndDeleteOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/FindOneAndDeleteOptions.html>`__ API Documentation |
158 |
| -- :manual:`db.collection.deleteOne() </reference/method/db.collection.deleteMany/>` Server Manual Entry |
159 |
| -- :manual:`db.collection.deleteMany() </reference/method/db.collection.deleteOne/>` Server Manual Entry |
160 |
| -- :manual:`db.collection.findOneAndDelete() </reference/method/db.collection.findOneAndDelete/>` Server Manual Entry |
| 187 | +API Documentation |
| 188 | +~~~~~~~~~~~~~~~~~ |
| 189 | + |
| 190 | +- `deleteOne() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#deleteOne(org.bson.conversions.Bson)>`__ |
| 191 | +- `deleteMany() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#deleteMany(org.bson.conversions.Bson)>`__ |
| 192 | +- `findOneAndDelete() <{+api+}/apidocs/mongodb-driver-sync/com/mongodb/client/MongoCollection.html#findOneAndDelete(org.bson.conversions.Bson)>`__ |
| 193 | +- `DeleteOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/DeleteOptions.html>`__ |
| 194 | +- `FindOneAndDeleteOptions <{+api+}/apidocs/mongodb-driver-core/com/mongodb/client/model/FindOneAndDeleteOptions.html>`__ |
| 195 | + |
| 196 | +Server Manual Entries |
| 197 | +~~~~~~~~~~~~~~~~~~~~~ |
| 198 | + |
| 199 | +- :manual:`db.collection.deleteOne() </reference/method/db.collection.deleteMany/>` |
| 200 | +- :manual:`db.collection.deleteMany() </reference/method/db.collection.deleteOne/>` |
| 201 | +- :manual:`db.collection.findOneAndDelete() </reference/method/db.collection.findOneAndDelete/>` |
0 commit comments