-
Notifications
You must be signed in to change notification settings - Fork 2
/
seed.js
27 lines (23 loc) · 822 Bytes
/
seed.js
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
26
27
const faker = require('faker');
const knex = require('./dbconnection').knex;
const itemHistoryInsert = require('./dbconnection').itemHistoryInsert;
async function seedDB() {
for (var i = 0; i < 1000; i++) {
//Insert item into Database
knex('inventory')
.insert({description: faker.commerce.productName(),
category: faker.commerce.department(),
date_recieved: faker.date.past(),
storage_location: faker.random.number() % 2000,
quantity: faker.random.number()})
.returning('*')
.then(result => {
itemHistoryInsert(result, "[email protected]", 'created item');
})
.catch(err => {
console.log(err);
});
//console.log(item);
}
}
module.exports = seedDB;