I'm trying to create a database generic model to base my other models off.
When making a create function I ran into the problem of Knex.js's insert function requires a argument with the type of:
TRecord extends CompositeTableType<unknown>
? ResolveTableType<TRecord, 'insert'> | ReadonlyArray<ResolveTableType<TRecord, 'insert'>>
: DbRecordArr<TRecord> | ReadonlyArray<DbRecordArr<TRecord>>
I'm trying to pass the data in from my function:
async create(data: TTableAttributes){
await this.knex.insert(data).returning("*").then((data) => { console.log(data); return data; });
}
}
Is there some way of transforming my parameter into the CompositeTableType so that it will work?
I have checked the documentation under Typescript Support and there's almost nothing about insert with Typescript.