INNER CODE UNIT · TypeScript

firstValue

margelo/react-native-nitro-sqlite · packages/react-native-nitro-sqlite-vec/src/index.ts:37

function firstValue<T>(db: NitroSQLiteConnection, sql: string): T {
  const row = db.execute(sql).rows?._array?.[0]
  return row?.value as T
}

/** Query the sqlite-vec version on an open connection.
 * @param db Open NitroSQLite connection. The query runs synchronously.
 * @returns The linked version string, for example `"v0.1.9"`.
 * @throws If `vec_version()` is unavailable or the query fails.
 */
export function vecVersion(db: NitroSQLiteConnection): string {
  return firstValue<string>(db, 'SELECT vec_version() AS value')
}

/** Check whether the version query succeeds on this connection.
 * @param db Open NitroSQLite connection. The check runs synchronously.
 * @returns `false` if the version query throws for any reason, including a closed connection.
 */

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…