Update mongodb

This commit is contained in:
syuilo
2018-10-16 11:38:09 +09:00
parent d32b2a8ce5
commit 9427a756c9
31 changed files with 83 additions and 52 deletions

View File

@@ -1,5 +1,6 @@
import * as mongo from 'mongodb';
import db from '../db/mongodb';
import isObjectId from '../misc/is-objectid';
const Following = db.get<IFollowing>('following');
Following.createIndex(['followerId', 'followeeId'], { unique: true });
@@ -32,7 +33,7 @@ export async function deleteFollowing(following: string | mongo.ObjectID | IFoll
let f: IFollowing;
// Populate
if (mongo.ObjectID.prototype.isPrototypeOf(following)) {
if (isObjectId(following)) {
f = await Following.findOne({
_id: following
});