diff options
| author | Tyler Schicke <tschicke@gmail.com> | 2020-01-04 22:41:08 -0800 |
|---|---|---|
| committer | Tyler Schicke <tschicke@gmail.com> | 2020-01-07 23:49:15 -0800 |
| commit | 23d5f6b28a93a3c66c0bd7776d6a42073cc55afb (patch) | |
| tree | 916d4209e7f401bb9bdc8c6d60cc333b06b23b27 /src/server/IDatabase.ts | |
| parent | da50d941f597fb3ec52bc3653d94f8c30affe552 (diff) | |
Added basic implementation of MemoryDatabase
Diffstat (limited to 'src/server/IDatabase.ts')
| -rw-r--r-- | src/server/IDatabase.ts | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/server/IDatabase.ts b/src/server/IDatabase.ts new file mode 100644 index 000000000..a7e3e2b0a --- /dev/null +++ b/src/server/IDatabase.ts @@ -0,0 +1,21 @@ +import * as mongodb from 'mongodb'; +import { Transferable } from './Message'; + +export const DocumentsCollection = 'documents'; +export const NewDocumentsCollection = 'newDocuments'; +export interface IDatabase { + update(id: string, value: any, callback: (err: mongodb.MongoError, res: mongodb.UpdateWriteOpResult) => void, upsert?: boolean, collectionName?: string): Promise<void>; + + replace(id: string, value: any, callback: (err: mongodb.MongoError, res: mongodb.UpdateWriteOpResult) => void, upsert?: boolean, collectionName?: string): void; + + delete(query: any, collectionName?: string): Promise<mongodb.DeleteWriteOpResultObject>; + delete(id: string, collectionName?: string): Promise<mongodb.DeleteWriteOpResultObject>; + + deleteAll(collectionName?: string, persist?: boolean): Promise<any>; + + insert(value: any, collectionName?: string): Promise<void>; + + getDocument(id: string, fn: (result?: Transferable) => void, collectionName?: string): void; + getDocuments(ids: string[], fn: (result?: Transferable[]) => void, collectionName?: string): void; + visit(ids: string[], fn: (result: any) => string[] | Promise<string[]>, collectionName?: string): Promise<void>; +} |
