Skip to content

Instantly share code, notes, and snippets.

@radzserg
Created October 4, 2019 14:56
Show Gist options
  • Select an option

  • Save radzserg/8ab082806bb1c9f21fa32e51af40f732 to your computer and use it in GitHub Desktop.

Select an option

Save radzserg/8ab082806bb1c9f21fa32e51af40f732 to your computer and use it in GitHub Desktop.
export class KnexStorageWriter implements IStorageWriter {
private knex: Knex;
constructor(knex: Knex) {
this.knex = knex;
}
insert = async (tableName: string, data: any, id: string = 'id') => {
const [result] = await this.knex(tableName).insert(data, [id]);
return {
...result,
...data,
};
};
}
const knex = configureKnex();
const storage = new KnexStorageWriter(knex);
const dbSeeder = new DbSeeder(storage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment