summaryrefslogtreecommitdiff
path: root/src/api/models
diff options
context:
space:
mode:
Diffstat (limited to 'src/api/models')
-rw-r--r--src/api/models/channel-watching.ts3
-rw-r--r--src/api/models/channel.ts14
-rw-r--r--src/api/models/drive-file.ts15
-rw-r--r--src/api/models/notification.ts5
-rw-r--r--src/api/models/post.ts3
5 files changed, 37 insertions, 3 deletions
diff --git a/src/api/models/channel-watching.ts b/src/api/models/channel-watching.ts
new file mode 100644
index 0000000000..6184ae408d
--- /dev/null
+++ b/src/api/models/channel-watching.ts
@@ -0,0 +1,3 @@
+import db from '../../db/mongodb';
+
+export default db.get('channel_watching') as any; // fuck type definition
diff --git a/src/api/models/channel.ts b/src/api/models/channel.ts
new file mode 100644
index 0000000000..c80e84dbc8
--- /dev/null
+++ b/src/api/models/channel.ts
@@ -0,0 +1,14 @@
+import * as mongo from 'mongodb';
+import db from '../../db/mongodb';
+
+const collection = db.get('channels');
+
+export default collection as any; // fuck type definition
+
+export type IChannel = {
+ _id: mongo.ObjectID;
+ created_at: Date;
+ title: string;
+ user_id: mongo.ObjectID;
+ index: number;
+};
diff --git a/src/api/models/drive-file.ts b/src/api/models/drive-file.ts
index 8d158cf563..8968d065cd 100644
--- a/src/api/models/drive-file.ts
+++ b/src/api/models/drive-file.ts
@@ -1,11 +1,22 @@
-import db from '../../db/mongodb';
+import * as mongodb from 'mongodb';
+import monkDb, { nativeDbConn } from '../../db/mongodb';
-const collection = db.get('drive_files');
+const collection = monkDb.get('drive_files.files');
(collection as any).createIndex('hash'); // fuck type definition
export default collection as any; // fuck type definition
+const getGridFSBucket = async (): Promise<mongodb.GridFSBucket> => {
+ const db = await nativeDbConn();
+ const bucket = new mongodb.GridFSBucket(db, {
+ bucketName: 'drive_files'
+ });
+ return bucket;
+};
+
+export { getGridFSBucket };
+
export function validateFileName(name: string): boolean {
return (
(name.trim().length > 0) &&
diff --git a/src/api/models/notification.ts b/src/api/models/notification.ts
index 1c1f429a0d..1065e8baaa 100644
--- a/src/api/models/notification.ts
+++ b/src/api/models/notification.ts
@@ -1,3 +1,8 @@
+import * as mongo from 'mongodb';
import db from '../../db/mongodb';
export default db.get('notifications') as any; // fuck type definition
+
+export interface INotification {
+ _id: mongo.ObjectID;
+}
diff --git a/src/api/models/post.ts b/src/api/models/post.ts
index 8b9f7f5ef6..7584ce182d 100644
--- a/src/api/models/post.ts
+++ b/src/api/models/post.ts
@@ -10,9 +10,10 @@ export function isValidText(text: string): boolean {
export type IPost = {
_id: mongo.ObjectID;
+ channel_id: mongo.ObjectID;
created_at: Date;
media_ids: mongo.ObjectID[];
- reply_to_id: mongo.ObjectID;
+ reply_id: mongo.ObjectID;
repost_id: mongo.ObjectID;
poll: {}; // todo
text: string;