diff --git a/loopbackMigration.js b/loopbackMigration.js index 02dd993b9c..1a86352e46 100644 --- a/loopbackMigration.js +++ b/loopbackMigration.js @@ -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); + } + );