backend/data/seeds/1 - accounts.js

62 lines
1.4 KiB
JavaScript
Raw Normal View History

const bcrypt = require('bcryptjs');
const { saltingRounds } = require('../../config/config');
2020-05-05 15:58:34 +00:00
exports.seed = function (knex) {
// Deletes ALL existing entries
return knex('account')
.del()
.then(function () {
const accountSeeds = [
2020-05-05 15:58:34 +00:00
{
username: 'liza',
email: 'liza@example.com',
password: 'password',
2020-05-05 15:58:34 +00:00
timezone: 'Europe/Brussels',
earliest_time: '00:00',
latest_time: '24:00',
2020-05-05 15:58:34 +00:00
},
{
username: 'emile',
email: 'emile@example.com',
password: 'password',
2020-05-05 15:58:34 +00:00
timezone: 'America/New_York',
earliest_time: '09:00',
latest_time: '20:00',
},
{
username: 'jack',
email: 'jack@example.com',
password: 'password',
2020-05-05 15:58:34 +00:00
timezone: 'Asia/Kolkata',
earliest_time: '10:30',
latest_time: '17:00',
},
{
username: 'cynthia',
email: 'cynthia@example.com',
password: 'password',
2020-05-05 15:58:34 +00:00
timezone: 'Europe/Brussels',
earliest_time: '06:30',
latest_time: '12:00',
},
{
username: 'celine',
email: 'celine@example.com',
password: 'password',
2020-05-05 15:58:34 +00:00
timezone: 'Europe/Brussels',
earliest_time: '10:30',
latest_time: '20:00',
},
];
// Hash password for each user
accountSeeds.forEach((account) => {
let hash = bcrypt.hashSync(account.password, saltingRounds);
account.password = hash;
});
// Inserts seed entries
return knex('account').insert(accountSeeds);
2020-05-05 15:58:34 +00:00
});
};