Update mongodb
This commit is contained in:
parent
d32b2a8ce5
commit
9427a756c9
31 changed files with 83 additions and 52 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue