Comparing version 3.6.0 to 3.7.0
@@ -29,2 +29,6 @@ import * as mongodb from 'mongodb' | ||
interface FindOneAndDeleteOption<T> extends Omit<mongodb.FindOneAndDeleteOption<T>, 'hint'> { | ||
hint?: string | object | ||
} | ||
declare function albatross (uri: string): albatross.Albatross | ||
@@ -75,2 +79,7 @@ | ||
findOneAndDelete (filter: mongodb.FilterQuery<TSchema>, options?: WithoutProjection<FindOneAndDeleteOption<TSchema>>): Promise<TSchema | null> | ||
findOneAndDelete<TKey extends keyof TSchema> (filter: mongodb.FilterQuery<TSchema>, options: SpecificProjection<FindOneAndDeleteOption<TSchema>, { [key in TKey]: 1 | true } & { _id: 0 | false }>): Promise<Pick<TSchema, TKey> | null> | ||
findOneAndDelete<TKey extends keyof TSchema> (filter: mongodb.FilterQuery<TSchema>, options: SpecificProjection<FindOneAndDeleteOption<TSchema>, { [key in TKey]: 1 | true } & { _id?: 1 | true }>): Promise<Pick<TSchema, '_id' | TKey> | null> | ||
findOneAndDelete (filter: mongodb.FilterQuery<TSchema>, options?: FindOneAndDeleteOption<TSchema>): Promise<object | null> | ||
aggregate (pipeline: object[], options?: mongodb.CollectionAggregationOptions): Promise<object[]> | ||
@@ -77,0 +86,0 @@ |
@@ -193,2 +193,16 @@ const debug = require('debug') | ||
async findOneAndDelete (filter, opts) { | ||
const db = await this.parent.db() | ||
try { | ||
this[kDebug]('findOneAndDelete(%o)', filter) | ||
const res = await db.collection(this.name).findOneAndDelete(filter, opts) | ||
this[kDebug](`reply OK ${res.value == null ? 0 : 1}`) | ||
return res.value | ||
} catch (err) { | ||
this[kDebug]('reply ERR') | ||
throw err | ||
} | ||
} | ||
async aggregate (pipeline, opts) { | ||
@@ -195,0 +209,0 @@ const db = await this.parent.db() |
{ | ||
"name": "albatross", | ||
"version": "3.6.0", | ||
"version": "3.7.0", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "author": "Linus Unnebäck <linus@folkdatorn.se>", |
@@ -188,2 +188,6 @@ # ![Albatross](/header.png?raw=true "Albatross") | ||
#### `findOneAndDelete(filter[, opts]): Promise<object>` | ||
Finds a document and deletes it in one atomic operation. | ||
#### `aggregate(pipeline[, opts]): Promise<object[]>` | ||
@@ -190,0 +194,0 @@ |
30075
486
257