bun
bun
Explore posts from servers
KKysely
Created by bun on 2/15/2024 in #help
Why does `.stream()` return a single result when I pass in a `chunkSize` option ?
I'm guessing it returns chunkSize mount of rows for each iteration, but shouldn't it be an array instead?
2 replies
KKysely
Created by bun on 12/20/2023 in #help
why does `fn.countAll` return `bigint` ?
need it to return a number
4 replies
KKysely
Created by bun on 9/20/2023 in #help
what is this error, i started getting it randomly
error: syntax error at or near ")"
at /Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/pg/lib/client.js:526:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PostgresConnection.executeQuery (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:69:28)
at async file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
at async #run (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/single-connection-provider.js:25:16)
at PostgresConnection.executeQuery (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:88:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
at async #run (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/single-connection-provider.js:25:16) {
length: 90,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '22',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'scan.l',
line: '1248',
routine: 'scanner_yyerror'
}
error: syntax error at or near ")"
at /Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/pg/lib/client.js:526:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async PostgresConnection.executeQuery (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:69:28)
at async file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
at async #run (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/single-connection-provider.js:25:16)
at PostgresConnection.executeQuery (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/dialect/postgres/postgres-driver.js:88:41)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/query-executor/query-executor-base.js:35:28
at async #run (file:///Users/username/Workspace/company/project/node_modules/.pnpm/[email protected]/node_modules/kysely/dist/esm/driver/single-connection-provider.js:25:16) {
length: 90,
severity: 'ERROR',
code: '42601',
detail: undefined,
hint: undefined,
position: '22',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'scan.l',
line: '1248',
routine: 'scanner_yyerror'
}
4 replies
KKysely
Created by bun on 9/4/2023 in #help
How to return last inserted ID ?
export async function createCommands(deviceId: number, commands: string[]) {
return db
.insertInto("commands")
.values(commands.map((c) => ({ deviceId, content: c })))
.returning("id")
.executeTakeFirstOrThrow()
}
export async function createCommands(deviceId: number, commands: string[]) {
return db
.insertInto("commands")
.values(commands.map((c) => ({ deviceId, content: c })))
.returning("id")
.executeTakeFirstOrThrow()
}
For this example, how do I only return the last inserted ID ?
8 replies
KKysely
Created by bun on 8/30/2023 in #query-showcase
how to sort `db.updateTable` returning values?
await db
.updateTable("users")
.where("id", "in", ({ selectFrom }) =>
selectFrom("users")
.where("users.status", "=", "PREPARED")
.where("profileId", "=", profileId)
.select("id")
.limit(100),
)
.set({ status: "SENT" })
.returningAll()
.orderBy("id", "asc") // why does this not exist?
.execute()
await db
.updateTable("users")
.where("id", "in", ({ selectFrom }) =>
selectFrom("users")
.where("users.status", "=", "PREPARED")
.where("profileId", "=", profileId)
.select("id")
.limit(100),
)
.set({ status: "SENT" })
.returningAll()
.orderBy("id", "asc") // why does this not exist?
.execute()
why cant i .orderBy("id", "asc") ?
7 replies
KKysely
Created by bun on 7/1/2023 in #help
is this uuid() correct in mysql?
export async function up(db: Kysely<any>): Promise<void> { await db.schema .createTable("Payment") .addColumn("id", "char", (col) => col.defaultTo(raw("UUID()")).primaryKey())
3 replies
KKysely
Created by bun on 6/29/2023 in #help
What's the pattern for writing migrations exactly?
I'm not familiar with SQL migrations, so my question is how do we create the migration files, what rules should it follow ? As seen in the kysely's GitHub repo example, the migration files have dates, but those files aren't generated, so where did the dates come from ? Well, let's say I don't want the migration files to have dates then I just create separate files for migrations and name them whatever? Ok, then how do I run them? Do I run them everytime the program starts ? Just help me out here, the docs doesn't mention anything about migrations I think it just assumes you are familiar with them already..
16 replies