feat: add cc-server-db

This commit is contained in:
2019-06-11 13:09:50 +08:00
parent 7d84393a3c
commit 73daf1e44e
18 changed files with 129 additions and 87 deletions

View File

@@ -0,0 +1,11 @@
export const DBClient = Symbol.for('DBClient')
export interface DBClient<T = any> {
find(collection: string, filter: object): Promise<T[]>;
findOne(collection: string, filter: Object): Promise<T>;
findOneById(collection: string, objectId: string): Promise<T>;
insertOne(collection: string, model: T): Promise<T>;
updateOne(collection: string, where: any, model: any): Promise<boolean>;
updateById(collection: string, objectId: string, model: any): Promise<boolean>;
deleteOne(collection: string, where: any): Promise<boolean>;
deleteById(collection: string, objectId: string): Promise<boolean>;
}