Escaped paramaters in raw sql
``ts
export async function getRandomAnswerByQuestionId({ questionId, answerLimit }: { questionId: string, answerLimit: number }) {
return sql
SELECT * FROM get_random_answers(${sql.val(questionId)}, ${sql.val(answerLimit)})`.execute(databaseClient);
}...sql.val
in this case
https://kyse.link/?p=s&i=MEBVYcJHvb7Uj4c6chaI...Should database tables mimic form fields?
Best practice around building query functions
Declaring types under 'kysely-codegen' module
./types/kysely-codegen.d.ts
file which contains ```ts
import { Insertable, Selectable, Updateable } from 'kysely';
import { User } from 'kysely-codegen';...From Prisma Model to Kysely Schema
[ERR_UNKNOWN_FILE_EXTENSION] when running migrations
Figuring out where in codebase an exception originated from
.execute()
call threw a SQL exception? I know ideally I should be doing error handling on each call, but I have a large codebase and I'm not sure where this error is coming from. Is there any easy way of figuring this out? Maybe a way to have a wrapper that prints out the query if malformed, or to print out the stack trace where the original call was executed?
```
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1. Trace: Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1...How to insert into all values (and columns) from another table / view?
Triggers vs stored procedures
updatedAt
and lastLogin
updated on their own from the Model below ```ts
model User {
id Int @id @default(autoincrement())
createdAt DateTime @default(now()) @db.Date
updatedAt DateTime @db.Timestamp() ...`Selectable`, `Insertable` and `Updateable` wrappers
export type Person = Selectable<PersonTable>
export type NewPerson = Insertable<PersonTable>
export type EditedPerson = Updateable<PersonTable>
export type Person = Selectable<PersonTable>
export type NewPerson = Insertable<PersonTable>
export type EditedPerson = Updateable<PersonTable>
How to sort by random?
orderBy(sql`random()`)
orderBy(sql`random()`)
Using jsonArrayFrom with mariadb.
insert data into a table that has id of type bigserial
Unable to connect to DB
Limit with a literal value
Prisma-kysely generator converts boolean to a number
prisma-kysely
, the generated type for a prisma Bool appears to be a number for some reason. Is this correct?Is there a way to not have as many Selectable<> generics?
prisma-kysely
to generate my Kysely types, and it generates them with the Generated generic. I therefore need to use the Selectable generic to change it to the return type of what is selected when I want to use the type. Is there a way to avoid using it so often?insertId return by transaction
How can I use Kysely migration inside NextJS 13 project?