-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathusers.js
More file actions
25 lines (24 loc) · 680 Bytes
/
users.js
File metadata and controls
25 lines (24 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const bcrypt = require('bcrypt')
const { faker } = require('@faker-js/faker')
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.seed = async function (knex) {
// Deletes ALL existing entries
await knex('users').del()
await knex('users').insert(
Array.from({ length: 5 }, (v, i) => {
return {
id: i,
email: `user${i}@demo.test`,
username: faker.name.firstName(),
password: bcrypt.hashSync(`user${i}pass`, 10),
bio: faker.lorem.sentences(),
image: faker.image.avatar(),
created_at: new Date().toISOString(),
updated_at: new Date().toISOString()
}
})
)
}