Better indexes

This commit is contained in:
syuilo 2018-10-29 21:53:40 +09:00
parent 24cfb93b2e
commit 5b84d29807
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
5 changed files with 9 additions and 0 deletions

View file

@ -5,6 +5,7 @@ import isObjectId from '../misc/is-objectid';
import { pack as packNote } from './note';
const Favorite = db.get<IFavorite>('favorites');
Favorite.createIndex('userId');
Favorite.createIndex(['userId', 'noteId'], { unique: true });
export default Favorite;

View file

@ -5,6 +5,8 @@ import isObjectId from '../misc/is-objectid';
import { pack as packUser } from './user';
const FollowRequest = db.get<IFollowRequest>('followRequests');
FollowRequest.createIndex('followerId');
FollowRequest.createIndex('followeeId');
FollowRequest.createIndex(['followerId', 'followeeId'], { unique: true });
export default FollowRequest;

View file

@ -2,6 +2,8 @@ import * as mongo from 'mongodb';
import db from '../db/mongodb';
const Following = db.get<IFollowing>('following');
Following.createIndex('followerId');
Following.createIndex('followeeId');
Following.createIndex(['followerId', 'followeeId'], { unique: true });
export default Following;

View file

@ -2,6 +2,8 @@ import * as mongo from 'mongodb';
import db from '../db/mongodb';
const NoteUnread = db.get<INoteUnread>('noteUnreads');
NoteUnread.createIndex('userId');
NoteUnread.createIndex('noteId');
NoteUnread.createIndex(['userId', 'noteId'], { unique: true });
export default NoteUnread;

View file

@ -2,6 +2,8 @@ import * as mongo from 'mongodb';
import db from '../db/mongodb';
const NoteWatching = db.get<INoteWatching>('noteWatching');
NoteWatching.createIndex('userId');
NoteWatching.createIndex('noteId');
NoteWatching.createIndex(['userId', 'noteId'], { unique: true });
export default NoteWatching;