cc-server-parent/packages/db/src/index.ts
2019-06-21 16:47:18 +08:00

13 lines
527 B
TypeScript

export const DBClient = Symbol.for('DBClient')
export interface DBClient<T = any> {
getProvide<P>(): P;
setTable(table: string): void;
find(filter: object): Promise<T[]>;
findOne(filter: Object): Promise<T>;
findOneById(objectId: string): Promise<T>;
insertOne(model: T): Promise<T>;
updateOne(where: any, model: any): Promise<boolean>;
updateById(objectId: string, model: any): Promise<boolean>;
deleteOne(where: any): Promise<boolean>;
deleteById(objectId: string): Promise<boolean>;
}