Skip to content

Commit 9eabebb

Browse files
committed
feat: allow passing meta to find options
1 parent 42865ff commit 9eabebb

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed

packages/core/src/query/findFirst.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ async function _findFirst<
6363
key: keyOrOptions,
6464
}
6565
: keyOrOptions
66+
67+
if (findOptions.meta) {
68+
Object.assign(meta, findOptions.meta)
69+
}
70+
6671
const fetchPolicy = store.$getFetchPolicy(findOptions?.fetchPolicy)
6772

6873
let result: any

packages/core/src/query/findMany.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ async function _findMany<
5959
meta ??= {}
6060
findOptions ??= {}
6161

62+
if (findOptions.meta) {
63+
Object.assign(meta, findOptions.meta)
64+
}
65+
6266
const fetchPolicy = store.$getFetchPolicy(findOptions.fetchPolicy)
6367

6468
let result: any[] | undefined

packages/core/src/query/peekFirst.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ export function peekFirst<
3535
key: keyOrOptions,
3636
}
3737
: keyOrOptions
38+
3839
const key = findOptions?.key
40+
41+
if (findOptions.meta) {
42+
Object.assign(meta, findOptions.meta)
43+
}
44+
3945
const fetchPolicy = store.$getFetchPolicy(findOptions?.fetchPolicy)
4046

4147
if (force || shouldReadCacheFromFetchPolicy(fetchPolicy)) {

packages/core/src/query/peekMany.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ export function peekMany<
3030
}: PeekManyOptions<TCollection, TCollectionDefaults, TSchema>): QueryResult<Array<WrappedItem<TCollection, TCollectionDefaults, TSchema>>> {
3131
meta ??= {}
3232

33+
if (findOptions?.meta) {
34+
Object.assign(meta, findOptions.meta)
35+
}
36+
3337
const fetchPolicy = store.$getFetchPolicy(findOptions?.fetchPolicy)
3438
if (force || shouldReadCacheFromFetchPolicy(fetchPolicy)) {
3539
let marker = defaultMarker(collection, findOptions)

packages/shared/src/types/query.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* eslint-disable unused-imports/no-unused-vars */
22

33
import type { Collection, CollectionByName, CollectionDefaults, CollectionRelation, RelationsByName, ResolvedCollectionItem, StoreSchema } from './collection'
4+
import type { CustomHookMeta } from './hooks'
45

56
export interface CustomParams<
67
TCollection extends Collection,
@@ -131,6 +132,8 @@ export interface FindOptionsBase<
131132
* Experimental: Enable garbage collection for items that are not referenced by any query or other item.
132133
*/
133134
experimentalGarbageCollection?: boolean
135+
136+
meta?: CustomHookMeta
134137
}
135138

136139
export type FindFirstOptions<

0 commit comments

Comments
 (0)