You can use the
remove() method to delete
some or all documents from a collection in a schema. The
X DevAPI provides additional methods for use with the
remove() method to filter and sort the
documents to be removed.
The example that follows passes a search condition to the
remove() method. All documents matching the
condition are removed from the
collection. In this example, one document matches the
mysql-py> db.countryinfo.remove("_id = 'SEA'") Query OK, 1 item affected (0.02 sec)
To remove the first document in the
countryinfo collection, use the
limit() method with a value of 1.
mysql-py> db.countryinfo.remove(True).limit(1) Query OK, 1 item affected (0.03 sec)
The following example removes the last document in the
countryinfo collection by country name.
mysql-py> db.countryinfo.remove(True).sort(["Name desc"]).limit(1) Query OK, 1 item affected (0.02 sec)
You can remove all documents in a collection. To do so, use
remove(True) method without specifying
a search condition.
Use care when you remove documents without specifying a search condition. This action will delete all documents from the collection.
See CollectionRemoveFunction for the full syntax definition.
See Section 20.4.2, “Download and Import world_x Database” for instructions to recreate the