23 lines
444 B
JavaScript
23 lines
444 B
JavaScript
const config = require('../config')
|
|
|
|
const getProducts = function () {
|
|
return [
|
|
{
|
|
productId: 'coc',
|
|
name: "Catalogue of Currencies"
|
|
}
|
|
]
|
|
}
|
|
|
|
exports.seed = async function (knex) {
|
|
const products = getProducts()
|
|
|
|
if (config.env.isProd) {
|
|
await knex('Product').whereIn('productId', products.map(d => d.productId)).del()
|
|
} else {
|
|
await knex('Product').del()
|
|
}
|
|
|
|
return Promise.all(products.map(a => knex('Product').insert(a)))
|
|
}
|