Make migration scripts

and use createdAt instead of _id
This commit is contained in:
syuilo
2018-04-02 23:19:07 +09:00
parent 5b80b6e901
commit 5ce6fa67d2
7 changed files with 90 additions and 4 deletions

View File

@ -42,10 +42,10 @@ module.exports = (params) => new Promise(async (res, rej) => {
for (let i = 0; i < 30; i++) {
graph.push(FollowedLog.findOne({
_id: { $lt: ObjectID.createFromTime(cursorTime / 1000) },
createdAt: { $lt: new Date(cursorTime / 1000) },
userId: user._id
}, {
sort: { _id: -1 },
sort: { createdAt: -1 },
}).then(log => {
cursorDate = new Date(today.getTime());
cursorTime = cursorDate.setDate(today.getDate() - i);

View File

@ -42,10 +42,10 @@ module.exports = (params) => new Promise(async (res, rej) => {
for (let i = 0; i < 30; i++) {
graph.push(FollowingLog.findOne({
_id: { $lt: ObjectID.createFromTime(cursorTime / 1000) },
createdAt: { $lt: new Date(cursorTime / 1000) },
userId: user._id
}, {
sort: { _id: -1 },
sort: { createdAt: -1 },
}).then(log => {
cursorDate = new Date(today.getTime());
cursorTime = cursorDate.setDate(today.getDate() - i);