node-go/packages/server/data/seeds/06_move.js

26 lines
1 KiB
JavaScript
Raw Normal View History

2020-01-30 07:44:06 +00:00
exports.seed = async function(knex) {
2020-01-30 07:44:06 +00:00
// Deletes ALL existing entries
return await knex('move').del()
.then(async function () {
2020-01-30 07:44:06 +00:00
// Inserts seed entries
await knex('game')
.where({player_black: 'user-one', player_white: 'user-two'})
.then(async ([game]) => await knex('move')
.returning('*')
.insert(
[
{player: 'black', point_x: 3, point_y: 3, number: 1, game_record: true, game: game.id, prior_move: null},
{player: 'white', point_x: 15, point_y: 15, number: 2, game_record: true, game: game.id, prior_move: 1},
{player: 'black', point_x: 4, point_y: 15, number: 3, game_record: true, game: game.id, prior_move: 2},
{player: 'white', point_x: 15, point_y: 4, number: 4, game_record: true, game: game.id, prior_move: 3},
]
)
.then(res => {console.log(res); return res;})
.catch(e => {console.log(e); return e;})
)
.then(() => {})
})
.then(() => {})
2020-01-30 07:44:06 +00:00
};