diff options
author | eug-vs <eug-vs@keemail.me> | 2020-06-28 16:18:20 +0300 |
---|---|---|
committer | eug-vs <eug-vs@keemail.me> | 2020-06-28 16:18:20 +0300 |
commit | 02b0da08155c6615a48b8d7f49648c19c1600020 (patch) | |
tree | 5916962aacc99214780cc9c9ede7a0b0df160d1b /populateDb.ts | |
parent | 302a76985cef867f509a4180387cc45e934452d5 (diff) | |
download | which-api-02b0da08155c6615a48b8d7f49648c19c1600020.tar.gz |
feat: create feedback service
Diffstat (limited to 'populateDb.ts')
-rw-r--r-- | populateDb.ts | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/populateDb.ts b/populateDb.ts index b3e46af..991c152 100644 --- a/populateDb.ts +++ b/populateDb.ts @@ -1,7 +1,7 @@ import mongoose from 'mongoose'; import bluebird from 'bluebird'; import _ from 'lodash'; -import { User, Poll, Vote } from 'which-types'; +import { User, Poll, Vote, Feedback } from 'which-types'; import app from './app'; @@ -71,6 +71,13 @@ const createVote = (userId: string, pollId: string): Promise<Vote> => { }, { user: { _id: userId }, authenticated: true }); }; +const createFeedback = (userId: string): Promise<Feedback> => { + return app.service('feedback').create({ + version: 'v1.0.0', + score: _.sample([1, 2, 3, 4, 5]), + content: 'Absolutely amazing!' + }, { user: { _id: userId }, authenticated: true }); +}; const populate = async () => { const users = await bluebird.map(names, name => createUser(name)); @@ -81,6 +88,10 @@ const populate = async () => { }); await bluebird.map(users, user => { + return createFeedback(user?._id || ''); + }); + + await bluebird.map(users, user => { const pollsToVote = _.sampleSize(polls, _.random(0, POLLS_AMOUNT)); return bluebird.map(pollsToVote, poll => createVote(user?._id || '', poll?._id || '')); }); |