Closed oscarthorn closed 1 year ago
Hey there @oscarthorn! Kysely table types aren't meant to be used directly in business logic. This is because their types can be complex, and differ based on operation (insert, update, select etc.). Kysely does however provide generics that help with this:
import {SelectType, InsertType, UpdateType} from 'kysely';
async getDevices(): Promise<SelectType<Device>[]> {
return this.db
.selectFrom('Device')
.selectAll()
.execute();
}
That being said in this case my advice would be to just remove the return type from the function and allow it to be inferred.
@valtyr Ah, thanks for the explanation!
Happy to help 😁
Hi!
Thanks for this library, just found it but it's very useful. I might be doing something wrong but I'm having problems with Dates. I'm using postgress. I have a model in prisma:
Which generates kysely type:
However a simple:
Gives:
If I change it created_at to Date type everything works as expected.
Edit: For anyone else that might have this issue a workaround seems to be adding
/// @kyselyType(Date)
to the prisma schema for these fields.