Update mongodb

This commit is contained in:
syuilo 2018-10-16 11:38:09 +09:00
parent d32b2a8ce5
commit 9427a756c9
No known key found for this signature in database
GPG key ID: BDC4C49D06AB9D69
31 changed files with 83 additions and 52 deletions

View file

@ -1,6 +1,7 @@
import * as mongo from 'mongodb';
const deepcopy = require('deepcopy');
import db from '../../../db/mongodb';
import isObjectId from '../../../misc/is-objectid';
import { IUser, pack as packUser } from '../../user';
const ReversiGame = db.get<IReversiGame>('reversiGames');
@ -62,7 +63,7 @@ export const pack = (
let _game: any;
// Populate the game if 'game' is ID
if (mongo.ObjectID.prototype.isPrototypeOf(game)) {
if (isObjectId(game)) {
_game = await ReversiGame.findOne({
_id: game
});
@ -76,7 +77,7 @@ export const pack = (
// Me
const meId: mongo.ObjectID = me
? mongo.ObjectID.prototype.isPrototypeOf(me)
? isObjectId(me)
? me as mongo.ObjectID
: typeof me === 'string'
? new mongo.ObjectID(me)

View file

@ -1,6 +1,7 @@
import * as mongo from 'mongodb';
const deepcopy = require('deepcopy');
import db from '../../../db/mongodb';
import isObjectId from '../../../misc/is-objectid';
import { IUser, pack as packUser } from '../../user';
const Matching = db.get<IMatching>('reversiMatchings');
@ -23,7 +24,7 @@ export const pack = (
// Me
const meId: mongo.ObjectID = me
? mongo.ObjectID.prototype.isPrototypeOf(me)
? isObjectId(me)
? me as mongo.ObjectID
: typeof me === 'string'
? new mongo.ObjectID(me)