From d3d5c89dc8eda5e7f4aa6da4f07577c5328c6485 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 29 Oct 2018 21:53:40 +0900 Subject: [PATCH] Better indexes --- src/models/favorite.ts | 1 + src/models/follow-request.ts | 2 ++ src/models/following.ts | 2 ++ src/models/note-unread.ts | 2 ++ src/models/note-watching.ts | 2 ++ 5 files changed, 9 insertions(+) diff --git a/src/models/favorite.ts b/src/models/favorite.ts index 1ec923c9e..5f3c328eb 100644 --- a/src/models/favorite.ts +++ b/src/models/favorite.ts @@ -5,6 +5,7 @@ import isObjectId from '../misc/is-objectid'; import { pack as packNote } from './note'; const Favorite = db.get('favorites'); +Favorite.createIndex('userId'); Favorite.createIndex(['userId', 'noteId'], { unique: true }); export default Favorite; diff --git a/src/models/follow-request.ts b/src/models/follow-request.ts index 02b2a85b9..50235b8a9 100644 --- a/src/models/follow-request.ts +++ b/src/models/follow-request.ts @@ -5,6 +5,8 @@ import isObjectId from '../misc/is-objectid'; import { pack as packUser } from './user'; const FollowRequest = db.get('followRequests'); +FollowRequest.createIndex('followerId'); +FollowRequest.createIndex('followeeId'); FollowRequest.createIndex(['followerId', 'followeeId'], { unique: true }); export default FollowRequest; diff --git a/src/models/following.ts b/src/models/following.ts index 58ede35a9..58d55bbee 100644 --- a/src/models/following.ts +++ b/src/models/following.ts @@ -2,6 +2,8 @@ import * as mongo from 'mongodb'; import db from '../db/mongodb'; const Following = db.get('following'); +Following.createIndex('followerId'); +Following.createIndex('followeeId'); Following.createIndex(['followerId', 'followeeId'], { unique: true }); export default Following; diff --git a/src/models/note-unread.ts b/src/models/note-unread.ts index 62408d23b..dd08640d8 100644 --- a/src/models/note-unread.ts +++ b/src/models/note-unread.ts @@ -2,6 +2,8 @@ import * as mongo from 'mongodb'; import db from '../db/mongodb'; const NoteUnread = db.get('noteUnreads'); +NoteUnread.createIndex('userId'); +NoteUnread.createIndex('noteId'); NoteUnread.createIndex(['userId', 'noteId'], { unique: true }); export default NoteUnread; diff --git a/src/models/note-watching.ts b/src/models/note-watching.ts index b5ef3b61b..83aaf8ad0 100644 --- a/src/models/note-watching.ts +++ b/src/models/note-watching.ts @@ -2,6 +2,8 @@ import * as mongo from 'mongodb'; import db from '../db/mongodb'; const NoteWatching = db.get('noteWatching'); +NoteWatching.createIndex('userId'); +NoteWatching.createIndex('noteId'); NoteWatching.createIndex(['userId', 'noteId'], { unique: true }); export default NoteWatching;