summaryrefslogtreecommitdiff
path: root/src/models/games/reversi/matching.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/models/games/reversi/matching.ts')
-rw-r--r--src/models/games/reversi/matching.ts45
1 files changed, 0 insertions, 45 deletions
diff --git a/src/models/games/reversi/matching.ts b/src/models/games/reversi/matching.ts
deleted file mode 100644
index ba2ac1bc05..0000000000
--- a/src/models/games/reversi/matching.ts
+++ /dev/null
@@ -1,45 +0,0 @@
-import * as mongo from 'mongodb';
-import * as deepcopy from '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');
-export default Matching;
-
-export interface IMatching {
- _id: mongo.ObjectID;
- createdAt: Date;
- parentId: mongo.ObjectID;
- childId: mongo.ObjectID;
-}
-
-/**
- * Pack an reversi matching for API response
- */
-export const pack = (
- matching: any,
- me?: string | mongo.ObjectID | IUser
-) => new Promise<any>(async (resolve, reject) => {
-
- // Me
- const meId: mongo.ObjectID = me
- ? isObjectId(me)
- ? me as mongo.ObjectID
- : typeof me === 'string'
- ? new mongo.ObjectID(me)
- : (me as IUser)._id
- : null;
-
- const _matching = deepcopy(matching);
-
- // Rename _id to id
- _matching.id = _matching._id;
- delete _matching._id;
-
- // Populate user
- _matching.parent = await packUser(_matching.parentId, meId);
- _matching.child = await packUser(_matching.childId, meId);
-
- resolve(_matching);
-});