deleteOne
Updated at:
Deletes a record from a collection.
Method definition
deleteOne(filter: object): Promise<MongoResult>Request parameters
Field name | Type | Required | Description |
|---|---|---|---|
| Object | Yes | The filter condition for the database operation. |
Example
Deletes the first record from the users collection where age is less than 18.
mpserverless.db.collection('users').deleteOne({
age: { $lt: 18 }
}).then((res) => {
const hasDeleted = res.affectedDocs > 0;
}).catch(console.error);Is this page helpful?