add comments migration to loopback script
parent
13590a1331
commit
2422663f34
|
@ -160,28 +160,46 @@ var storyCount = dbObservable
|
|||
})
|
||||
.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(
|
||||
userIdentityCount,
|
||||
userSavesCount,
|
||||
storyCount,
|
||||
function(userIdentCount, userCount, storyCount) {
|
||||
commentCount,
|
||||
function(userIdentCount, userCount, storyCount, commentCount) {
|
||||
return {
|
||||
userIdentCount: userIdentCount * 20,
|
||||
userCount: userCount * 20,
|
||||
storyCount: storyCount * 20
|
||||
storyCount: storyCount * 20,
|
||||
commentCount: commentCount * 20
|
||||
};
|
||||
})
|
||||
.subscribe(
|
||||
function(countObj) {
|
||||
console.log('next');
|
||||
count = countObj;
|
||||
},
|
||||
function(err) {
|
||||
console.error('an error occured', err, err.stack);
|
||||
},
|
||||
function() {
|
||||
function(countObj) {
|
||||
console.log('next');
|
||||
count = countObj;
|
||||
},
|
||||
function(err) {
|
||||
console.error('an error occured', err, err.stack);
|
||||
},
|
||||
function() {
|
||||
|
||||
console.log('finished with ', count);
|
||||
process.exit(0);
|
||||
}
|
||||
);
|
||||
console.log('finished with ', count);
|
||||
process.exit(0);
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue