add comments migration to loopback script
This commit is contained in:
@ -160,28 +160,46 @@ var storyCount = dbObservable
|
|||||||
})
|
})
|
||||||
.count();
|
.count();
|
||||||
|
|
||||||
|
var commentCount = dbObservable
|
||||||
|
.flatMap(function(db) {
|
||||||
|
return createQuery(db, 'comments', {});
|
||||||
|
})
|
||||||
|
.withLatestFrom(dbObservable, function(comments, db) {
|
||||||
|
return {
|
||||||
|
comments: comments,
|
||||||
|
db: db
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.flatMap(function(dats) {
|
||||||
|
return insertMany(dats.db, 'comment', dats.comments, { w: 1 });
|
||||||
|
})
|
||||||
|
.buffer(20)
|
||||||
|
.count();
|
||||||
|
|
||||||
Rx.Observable.combineLatest(
|
Rx.Observable.combineLatest(
|
||||||
userIdentityCount,
|
userIdentityCount,
|
||||||
userSavesCount,
|
userSavesCount,
|
||||||
storyCount,
|
storyCount,
|
||||||
function(userIdentCount, userCount, storyCount) {
|
commentCount,
|
||||||
|
function(userIdentCount, userCount, storyCount, commentCount) {
|
||||||
return {
|
return {
|
||||||
userIdentCount: userIdentCount * 20,
|
userIdentCount: userIdentCount * 20,
|
||||||
userCount: userCount * 20,
|
userCount: userCount * 20,
|
||||||
storyCount: storyCount * 20
|
storyCount: storyCount * 20,
|
||||||
|
commentCount: commentCount * 20
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
.subscribe(
|
.subscribe(
|
||||||
function(countObj) {
|
function(countObj) {
|
||||||
console.log('next');
|
console.log('next');
|
||||||
count = countObj;
|
count = countObj;
|
||||||
},
|
},
|
||||||
function(err) {
|
function(err) {
|
||||||
console.error('an error occured', err, err.stack);
|
console.error('an error occured', err, err.stack);
|
||||||
},
|
},
|
||||||
function() {
|
function() {
|
||||||
|
|
||||||
console.log('finished with ', count);
|
console.log('finished with ', count);
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user