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

Function fromRowsObject

examples/react-native/shopping-list/src/db/collections.ts:56–75  ·  view source on GitHub ↗
(
    rows: SQLiteResultWithRows[`rows`],
  )

Source from the content-addressed store, hash-verified

54
55function extractRows(result: unknown): Array<Record<string, unknown>> {
56 const fromRowsObject = (
57 rows: SQLiteResultWithRows[`rows`],
58 ): Array<Record<string, unknown>> | null => {
59 if (!rows) return null
60 if (Array.isArray(rows._array)) {
61 return rows._array
62 }
63 if (typeof rows.length === `number` && typeof rows.item === `function`) {
64 const item = rows.item as (index: number) => unknown
65 const extracted: Array<Record<string, unknown>> = []
66 for (let i = 0; i < rows.length; i++) {
67 const row = item(i)
68 if (row && typeof row === `object`) {
69 extracted.push(row as Record<string, unknown>)
70 }
71 }
72 return extracted
73 }
74 return null
75 }
76
77 if (Array.isArray(result)) {
78 if (result.length === 0) return []

Callers 1

extractRowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected