summaryrefslogtreecommitdiff
path: root/src/server/api/endpoints/othello/games.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/api/endpoints/othello/games.ts')
-rw-r--r--src/server/api/endpoints/othello/games.ts28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/server/api/endpoints/othello/games.ts b/src/server/api/endpoints/othello/games.ts
index 2a6bbb4043..37fa384189 100644
--- a/src/server/api/endpoints/othello/games.ts
+++ b/src/server/api/endpoints/othello/games.ts
@@ -1,5 +1,5 @@
import $ from 'cafy';
-import Game, { pack } from '../../models/othello-game';
+import OthelloGame, { pack } from '../../models/othello-game';
module.exports = (params, user) => new Promise(async (res, rej) => {
// Get 'my' parameter
@@ -10,28 +10,28 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
const [limit = 10, limitErr] = $(params.limit).optional.number().range(1, 100).$;
if (limitErr) return rej('invalid limit param');
- // Get 'since_id' parameter
- const [sinceId, sinceIdErr] = $(params.since_id).optional.id().$;
- if (sinceIdErr) return rej('invalid since_id param');
+ // Get 'sinceId' parameter
+ const [sinceId, sinceIdErr] = $(params.sinceId).optional.id().$;
+ if (sinceIdErr) return rej('invalid sinceId param');
- // Get 'until_id' parameter
- const [untilId, untilIdErr] = $(params.until_id).optional.id().$;
- if (untilIdErr) return rej('invalid until_id param');
+ // Get 'untilId' parameter
+ const [untilId, untilIdErr] = $(params.untilId).optional.id().$;
+ if (untilIdErr) return rej('invalid untilId param');
- // Check if both of since_id and until_id is specified
+ // Check if both of sinceId and untilId is specified
if (sinceId && untilId) {
- return rej('cannot set since_id and until_id');
+ return rej('cannot set sinceId and untilId');
}
const q: any = my ? {
- is_started: true,
+ isStarted: true,
$or: [{
- user1_id: user._id
+ user1Id: user._id
}, {
- user2_id: user._id
+ user2Id: user._id
}]
} : {
- is_started: true
+ isStarted: true
};
const sort = {
@@ -50,7 +50,7 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
}
// Fetch games
- const games = await Game.find(q, {
+ const games = await OthelloGame.find(q, {
sort,
limit
});