Skip to content

Commit

Permalink
chore: debug libsql timing
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Nov 8, 2024
1 parent e345fdc commit 2f20087
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/runtime/adapters/libsql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ export default createDatabaseAdapter<{ url: string, authToken: string }>((opts)

return {
async all<T>(sql: string, params?: Array<number | string | boolean>): Promise<T[]> {
const now = Date.now()
const res = await client.execute({ sql, args: params || [] })

console.log(`[all] ${res.rows.length} rows in ${Date.now() - now}ms`)
return res.rows as T[]
},
async first<T>(sql: string, params?: Array<number | string | boolean>) {
const now = Date.now()
const res = await client.execute({ sql, args: params || [] })

console.log(`[first] ${JSON.stringify(res.rows[0])} in ${Date.now() - now}ms`)
return res.rows[0] as T
},
async exec(sql: string): Promise<void> {
Expand Down

0 comments on commit 2f20087

Please sign in to comment.