MCPcopy Create free account
hub / github.com/TanStack/db / readSqlScalar

Function readSqlScalar

packages/capacitor-db-sqlite-persistence/e2e/run-ios-e2e.ts:189–214  ·  view source on GitHub ↗
(
  databasePath: string,
  sql: string,
)

Source from the content-addressed store, hash-verified

187}
188
189async function readSqlScalar(
190 databasePath: string,
191 sql: string,
192): Promise<string | null> {
193 return new Promise((resolvePromise, rejectPromise) => {
194 let output = ``
195 const child = spawn(`sqlite3`, [databasePath, sql], {
196 cwd: appDirectory,
197 stdio: [`ignore`, `pipe`, `ignore`],
198 })
199
200 child.stdout.on(`data`, (chunk) => {
201 output += String(chunk)
202 })
203 child.on(`exit`, (code) => {
204 if (code === 0) {
205 const trimmed = output.trim()
206 resolvePromise(trimmed.length > 0 ? trimmed : null)
207 return
208 }
209
210 rejectPromise(new Error(`sqlite3 query failed`))
211 })
212 child.on(`error`, rejectPromise)
213 })
214}
215
216async function waitForResult(): Promise<RuntimeResultRow> {
217 const simulatorId = await resolveSimulatorId()

Callers 1

waitForResultFunction · 0.70

Calls 1

onMethod · 0.45

Tested by

no test coverage detected