-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add aggregate() & index.d.ts (#9)
* refacor: update deps * feat: add aggregate * feat: add index.d.ts * test: test aggregate
- Loading branch information
Showing
6 changed files
with
174 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import { | ||
CollectionInsertOneOptions, | ||
UpdateWriteOpResult, | ||
Collection, | ||
FindOneAndReplaceOption, | ||
Db, | ||
IndexOptions, | ||
InsertOneWriteOpResult, | ||
InsertWriteOpResult, | ||
CollectionInsertManyOptions, | ||
FindAndModifyWriteOpResultObject, | ||
MongoCountPreferences, | ||
ReadPreference, | ||
CollectionOptions, | ||
CollectionCreateOptions, | ||
} from 'mongodb'; | ||
|
||
declare class MongoDB { | ||
public db: Db; | ||
|
||
public connect(url: string): Promise<Db>; | ||
|
||
public insertOne( | ||
name: string, | ||
args?: { doc: Object; options?: CollectionInsertOneOptions } | ||
): Promise<InsertOneWriteOpResult>; | ||
|
||
public insertMany( | ||
name: string, | ||
args?: { docs: Object[]; options?: CollectionInsertManyOptions } | ||
): Promise<InsertWriteOpResult>; | ||
|
||
public findOneAndUpdate( | ||
name: string, | ||
args?: { | ||
filter: Object; | ||
update: Object; | ||
options?: FindOneAndReplaceOption; | ||
} | ||
): Promise<FindAndModifyWriteOpResultObject>; | ||
|
||
public findOneAndReplace( | ||
name: string, | ||
args?: { | ||
filter: Object; | ||
replacement: Object; | ||
options?: FindOneAndReplaceOption; | ||
} | ||
): Promise<FindAndModifyWriteOpResultObject>; | ||
|
||
public findOneAndDelete( | ||
name: string, | ||
args?: { | ||
filter: Object; | ||
options?: { projection?: Object; sort?: Object; maxTimeMS?: number }; | ||
} | ||
): Promise<FindAndModifyWriteOpResultObject>; | ||
|
||
public updateMany( | ||
name: string, | ||
args: { | ||
filter: Object; | ||
update: Object; | ||
options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean }; | ||
} | ||
): Promise<UpdateWriteOpResult>; | ||
|
||
public deleteMany( | ||
name: string, | ||
args: { filter: any; options?: CollectionOptions } | ||
): Promise<number>; | ||
|
||
public find( | ||
name: string, | ||
args: { | ||
query: any; | ||
skip?: number; | ||
limit?: number; | ||
project?: any; | ||
sort?: { [key: string]: number }; | ||
} | ||
): Promise<any[]>; | ||
|
||
public count( | ||
name: string, | ||
args: { | ||
query: any; | ||
options?: MongoCountPreferences; | ||
} | ||
): number; | ||
|
||
public distinct( | ||
name: string, | ||
args?: { | ||
key?: string; | ||
query?: any; | ||
options?: { readPreference?: ReadPreference | string }; | ||
} | ||
): Promise<any[]>; | ||
|
||
public createIndex( | ||
name: string, | ||
args: { fieldOrSpec: string | any; options?: IndexOptions } | ||
): Promise<string>; | ||
|
||
public listCollections(args?: { | ||
filter?: any; | ||
options?: { batchSize?: number; readPreference?: ReadPreference | string }; | ||
}): Promise<string[]>; | ||
|
||
public createCollection(args: { | ||
name: string; | ||
options?: CollectionCreateOptions; | ||
}): Promise<Collection>; | ||
|
||
public aggregate(name: string, pipeline: Object[]): Promise<any[]>; | ||
} | ||
|
||
export default MongoDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters