From 161fd4afab323ca6bf491def473f84bb7557b481 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 7 Mar 2018 17:48:32 +0900 Subject: wip --- src/api/endpoints/othello/invitations.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/api/endpoints/othello/invitations.ts (limited to 'src/api/endpoints/othello/invitations.ts') diff --git a/src/api/endpoints/othello/invitations.ts b/src/api/endpoints/othello/invitations.ts new file mode 100644 index 0000000000..f462ef0bf9 --- /dev/null +++ b/src/api/endpoints/othello/invitations.ts @@ -0,0 +1,11 @@ +import Matching, { pack as packMatching } from '../../models/othello-matching'; + +module.exports = (params, user) => new Promise(async (res, rej) => { + // Find session + const invitations = await Matching.find({ + child_id: user._id + }); + + // Reponse + res(Promise.all(invitations.map(async (i) => await packMatching(i, user)))); +}); -- cgit v1.2.3-freya From a53874edc265f6cd1aab54dbbbfcd996e81aec17 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 7 Mar 2018 18:56:55 +0900 Subject: wip --- src/api/endpoints/othello/games.ts | 6 +++++- src/api/endpoints/othello/invitations.ts | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src/api/endpoints/othello/invitations.ts') diff --git a/src/api/endpoints/othello/games.ts b/src/api/endpoints/othello/games.ts index da85de1c1f..39963fcd29 100644 --- a/src/api/endpoints/othello/games.ts +++ b/src/api/endpoints/othello/games.ts @@ -15,7 +15,11 @@ module.exports = (params, user) => new Promise(async (res, rej) => { } : {}; // Fetch games - const games = await Game.find(q); + const games = await Game.find(q, { + sort: { + _id: -1 + } + }); // Reponse res(Promise.all(games.map(async (g) => await pack(g, user)))); diff --git a/src/api/endpoints/othello/invitations.ts b/src/api/endpoints/othello/invitations.ts index f462ef0bf9..02fb421fbc 100644 --- a/src/api/endpoints/othello/invitations.ts +++ b/src/api/endpoints/othello/invitations.ts @@ -4,6 +4,10 @@ module.exports = (params, user) => new Promise(async (res, rej) => { // Find session const invitations = await Matching.find({ child_id: user._id + }, { + sort: { + _id: -1 + } }); // Reponse -- cgit v1.2.3-freya