2020-07-29 20:56:03 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
const faker = require ('faker');
|
|
|
|
|
|
|
|
function create_log () {
|
2020-07-30 18:39:37 +02:00
|
|
|
const data = {
|
|
|
|
num1: faker.random.number (),
|
|
|
|
num2: faker.random.number (),
|
|
|
|
num3: faker.random.number ()
|
|
|
|
};
|
2020-07-29 20:56:03 +02:00
|
|
|
return {
|
|
|
|
app: faker.random.word (),
|
|
|
|
message: faker.random.words (),
|
2020-07-30 18:39:37 +02:00
|
|
|
data: JSON.stringify (data),
|
2020-07-29 20:56:03 +02:00
|
|
|
timestamp: faker.date.recent ()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
async function seed (knex) {
|
|
|
|
console.log ('creating seeds');
|
2020-07-30 18:39:37 +02:00
|
|
|
const log = (Array (100))
|
|
|
|
.fill (() => null)
|
|
|
|
.map (() => create_log ());
|
|
|
|
await knex ('log')
|
|
|
|
.del ();
|
|
|
|
|
|
|
|
await knex.batchInsert ('log', log, 10);
|
2020-07-29 20:56:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { seed };
|