import { Knex } from "knex"; export async function seed(knex: Knex): Promise<void> { await knex('students').del(); await knex('teachers').del(); const [teacher_id] = await knex.insert({ name: "Bob", date_of_birth: "1970-01-01" }).into('teachers').returning('id'); return await knex.insert([{ name: "Peter", level: 25, date_of_birth: "1995-05-15", teacher_id: teacher_id },{ name:"John", level: 25, date_of_birth: "1985-06-16", teacher_id: teacher_id },{ name:"Simon", level: 25, date_of_birth: "1987-07-17", teacher_id: null } ]).into('students'); };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter