sort user timeline by date (#3210)

This commit is contained in:
MeiMei
2018-11-13 01:17:59 +09:00
committed by syuilo
parent 50824a7245
commit 81805b01cc
7 changed files with 19 additions and 13 deletions

View File

@ -153,9 +153,7 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
}
//#region Construct query
const sort = {
_id: -1
};
const sort = { } as any;
const query = {
deletedAt: null,
@ -168,15 +166,17 @@ export default define(meta, (ps, me) => new Promise(async (res, rej) => {
$gt: ps.sinceId
};
} else if (ps.untilId) {
sort._id = -1;
query._id = {
$lt: ps.untilId
};
} else if (ps.sinceDate) {
sort._id = 1;
sort.createdAt = 1;
query.createdAt = {
$gt: new Date(ps.sinceDate)
};
} else if (ps.untilDate) {
sort.createdAt = -1;
query.createdAt = {
$lt: new Date(ps.untilDate)
};