Skip to content
Source
Sign inSign up
TanStack/db

[repro] findOne returns array instead of single object in angular-db (issue #1261) #1272

Closedclaude[bot](GitHub profile, opens in a new tab)wants to merge 3 commits intomain fromai/issue-1261-reproopened

Showing 2 changed files with 138 additions and 0 deletions (loading 1).

x
0 of 2 viewed, 2 left
138 additions and 0 deletionspackages/angular-db/tests/inject-live-query.test-d.tsAdded
View file
@@ -0,0 +1,138 @@
+import { describe, expectTypeOf, it } from 'vitest'
+import { createCollection } from '../../db/src/collection/index'
+import { mockSyncCollectionOptions } from '../../db/tests/utils'
+import {
+ createLiveQueryCollection,
+ eq,
+ liveQueryCollectionOptions,
+} from '../../db/src/query/index'
+import { injectLiveQuery } from '../src/index'
+import type { SingleResult } from '../../db/src/types'
+​
+type Person = {
+ id: string
+ name: string
+ age: number
+ email: string
+ isActive: boolean
+ team: string
+}
+​
+describe(`injectLiveQuery type assertions`, () => {
+ it(`should type findOne query builder to return a single row`, () => {
+ const collection = createCollection(
+ mockSyncCollectionOptions<Person>({
+ id: `test-persons-findone-angular`,
+ getKey: (person: Person) => person.id,
+ initialData: [],