wip
This commit is contained in:
parent
06eabcbc63
commit
6c495268ae
15 changed files with 230 additions and 95 deletions
11
src/api/models/othello-matching.ts
Normal file
11
src/api/models/othello-matching.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import * as mongo from 'mongodb';
|
||||
import db from '../../db/mongodb';
|
||||
|
||||
const Matching = db.get<IMatching>('othello_matchings');
|
||||
export default Matching;
|
||||
|
||||
export interface IMatching {
|
||||
_id: mongo.ObjectID;
|
||||
parent_id: mongo.ObjectID;
|
||||
child_id: mongo.ObjectID;
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
import * as mongo from 'mongodb';
|
||||
import deepcopy = require('deepcopy');
|
||||
import db from '../../db/mongodb';
|
||||
|
||||
const Session = db.get<ISession>('othello_sessions');
|
||||
export default Session;
|
||||
|
||||
export interface ISession {
|
||||
_id: mongo.ObjectID;
|
||||
code: string;
|
||||
user_id: mongo.ObjectID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pack an othello session for API response
|
||||
*
|
||||
* @param {any} session
|
||||
* @return {Promise<any>}
|
||||
*/
|
||||
export const pack = (
|
||||
session: any
|
||||
) => new Promise<any>(async (resolve, reject) => {
|
||||
|
||||
const _session = deepcopy(session);
|
||||
|
||||
delete _session._id;
|
||||
|
||||
resolve(_session);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue