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

@@ -2,6 +2,7 @@ import * as mongo from 'mongodb';
const deepcopy = require('deepcopy');
import AccessToken from './access-token';
import db from '../db/mongodb';
import isObjectId from '../misc/is-objectid';
import config from '../config';
const App = db.get<IApp>('apps');
@@ -43,7 +44,7 @@ export const pack = (
let _app: any;
// Populate the app if 'app' is ID
if (mongo.ObjectID.prototype.isPrototypeOf(app)) {
if (isObjectId(app)) {
_app = await App.findOne({
_id: app
});
@@ -56,7 +57,7 @@ export const pack = (
}
// Me
if (me && !mongo.ObjectID.prototype.isPrototypeOf(me)) {
if (me && !isObjectId(me)) {
if (typeof me === 'string') {
me = new mongo.ObjectID(me);
} else {