ts-typed-sql
ts-typed-sql copied to clipboard
Move fromItemToOutRow to table instance it self
I want to be able to do
export const tbl = s.table("tbl", { test: tInteger });
type Tbl = typeof tbl.$rowInstance;
// instead of
type Tbl = FromItemToOutRow<typeof tbl>;
(or similar)
$rowInstance would be a useless (i.e. unused) field. What is the advantage of typeof tbl.$rowInstance; over FromItemToOutRow<typeof tbl>?
Say I have imported from, myTable, db from somewhere and write a function like this:
async function getSomething() {
return await db.exec(from(myTable).select(myTable.$all));
}
async function doSomething(myTableInstance: typeof myTable.$rowInstance) {
...
}
i.e. I have imported the table definition, but not FromItemToOutRow. Now i could just specify the argument type for doSomething using typeof myTable.$rowInstance instead of having to add more imports or declaring that type somewhere else and importing it.