aboutsummaryrefslogtreecommitdiff
path: root/src/server/IDatabase.ts
diff options
context:
space:
mode:
authorTyler Schicke <tschicke@gmail.com>2020-01-04 22:41:08 -0800
committerTyler Schicke <tschicke@gmail.com>2020-01-07 23:49:15 -0800
commit23d5f6b28a93a3c66c0bd7776d6a42073cc55afb (patch)
tree916d4209e7f401bb9bdc8c6d60cc333b06b23b27 /src/server/IDatabase.ts
parentda50d941f597fb3ec52bc3653d94f8c30affe552 (diff)
Added basic implementation of MemoryDatabase
Diffstat (limited to 'src/server/IDatabase.ts')
-rw-r--r--src/server/IDatabase.ts21
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>;
+}