node v2 cli support (#36309)
This commit is contained in:
parent
27e1692848
commit
a1b274e6f8
75 changed files with 1502 additions and 367 deletions
21
packages/tui/src/editor-zed-sqlite.node.ts
Normal file
21
packages/tui/src/editor-zed-sqlite.node.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { DatabaseSync, type SQLInputValue } from "node:sqlite"
|
||||
|
||||
export class Database {
|
||||
readonly #database: DatabaseSync
|
||||
|
||||
constructor(file: string, options?: { readonly?: boolean }) {
|
||||
this.#database = new DatabaseSync(file, { readOnly: options?.readonly })
|
||||
}
|
||||
|
||||
query(sql: string) {
|
||||
const statement = this.#database.prepare(sql)
|
||||
return {
|
||||
all: (parameters?: Record<string, SQLInputValue>) => (parameters ? statement.all(parameters) : statement.all()),
|
||||
get: (parameters?: Record<string, SQLInputValue>) => (parameters ? statement.get(parameters) : statement.get()),
|
||||
}
|
||||
}
|
||||
|
||||
close() {
|
||||
this.#database.close()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue