add comments migration to loopback script

pull/1135/merge
Berkeley Martinez 2015-06-25 21:47:25 -07:00
parent 13590a1331
commit 2422663f34
1 changed files with 32 additions and 14 deletions

View File

@ -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);
}
);