Created
October 4, 2019 14:56
-
-
Save radzserg/8ab082806bb1c9f21fa32e51af40f732 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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