mongodb#DeleteWriteOpResultObject TypeScript Examples
The following examples show how to use
mongodb#DeleteWriteOpResultObject.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: delete.ts From payload with MIT License | 6 votes |
async function handleDelete(args: PreferenceRequest): Promise<DeleteWriteOpResultObject> {
const { preferences: { Model } } = this;
const {
overrideAccess,
req,
user,
key,
} = args;
if (!user) {
throw new UnauthorizedError();
}
if (!overrideAccess) {
await executeAccess({ req }, defaultAccess);
}
const filter = {
key,
user: user.id,
userCollection: user.collection,
};
const result = await Model.findOneAndDelete(filter);
if (result.deletedCount === 0) {
throw new NotFound();
}
return result;
}
Example #2
Source File: Database.ts From discord-statuspage-v2 with MIT License | 5 votes |
async deleteWebhook (id: string, token: string): Promise<DeleteWriteOpResultObject> {
return await this.db.collection('webhooks').deleteOne({ id, token })
}
Example #3
Source File: index.ts From integration-services with Apache License 2.0 | 5 votes |
static async removeDocument(collectionName: string, query: any, options?: CommonOptions): Promise<DeleteWriteOpResultObject | undefined> {
const collection = MongoDbService.getCollection(collectionName);
return collection?.deleteOne(query, options);
}
Example #4
Source File: index.ts From integration-services with Apache License 2.0 | 5 votes |
static async removeDocuments(
collectionName: string,
query: any,
options?: CommonOptions
): Promise<DeleteWriteOpResultObject | undefined> {
const collection = MongoDbService.getCollection(collectionName);
return collection?.deleteMany(query, options);
}