react-query-firebase 2.3.2 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/react-native/firestore/useInfiniteQuery.d.ts +1 -1
- package/react-native/firestore/useInfiniteQuery.ts +2 -2
- package/react-native/firestore/useQueryConstraints.d.ts +3 -2
- package/react-native/firestore/useQueryConstraints.ts +12 -3
- package/web/firestore/useInfiniteQuery.d.ts +1 -1
- package/web/firestore/useInfiniteQuery.ts +2 -2
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
9
9
|
/**
|
|
10
10
|
* Reqct-query options that must include queryKey and shall not define queryFn
|
|
11
11
|
*/
|
|
12
|
-
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey,
|
|
12
|
+
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryFn"> & Required<Pick<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryKey">>;
|
|
13
13
|
/**
|
|
14
14
|
* Reference to a Firestore collection
|
|
15
15
|
*/
|
|
@@ -30,7 +30,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
30
30
|
InfiniteData<AppModelType[]>,
|
|
31
31
|
AppModelType[],
|
|
32
32
|
TQueryKey,
|
|
33
|
-
|
|
33
|
+
QueryNonFilterConstraint
|
|
34
34
|
>,
|
|
35
35
|
"queryFn"
|
|
36
36
|
> &
|
|
@@ -42,7 +42,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
42
42
|
InfiniteData<AppModelType[]>,
|
|
43
43
|
AppModelType[],
|
|
44
44
|
TQueryKey,
|
|
45
|
-
|
|
45
|
+
QueryNonFilterConstraint
|
|
46
46
|
>,
|
|
47
47
|
"queryKey"
|
|
48
48
|
>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type QueryNonFilterConstraint } from "@react-native-firebase/firestore";
|
|
1
2
|
import { AppModel } from "../../types/AppModel";
|
|
2
3
|
import { type NonFilterQueryConstraint } from "../../types/QueryConstraints";
|
|
3
4
|
/**
|
|
@@ -29,7 +30,7 @@ export type UseQueryConstraints<AppModelType extends AppModel = AppModel> = {
|
|
|
29
30
|
* };
|
|
30
31
|
* ```
|
|
31
32
|
*/
|
|
32
|
-
export declare const buildQueryConstraint: <AppModelType extends AppModel = AppModel>(constraint: NonFilterQueryConstraint<AppModelType>) =>
|
|
33
|
+
export declare const buildQueryConstraint: <AppModelType extends AppModel = AppModel>(constraint: NonFilterQueryConstraint<AppModelType>) => QueryNonFilterConstraint;
|
|
33
34
|
/**
|
|
34
35
|
* A hook to build a list of non-filter query constraints for firebase queries.
|
|
35
36
|
* It uses buildQueryConstraint method and useMemo hook.
|
|
@@ -51,4 +52,4 @@ export declare const buildQueryConstraint: <AppModelType extends AppModel = AppM
|
|
|
51
52
|
* ]};
|
|
52
53
|
* ```
|
|
53
54
|
*/
|
|
54
|
-
export declare const useQueryConstraints: <AppModelType extends AppModel = AppModel>({ constraints }: UseQueryConstraints<AppModelType>) =>
|
|
55
|
+
export declare const useQueryConstraints: <AppModelType extends AppModel = AppModel>({ constraints }: UseQueryConstraints<AppModelType>) => QueryNonFilterConstraint[];
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
startAt,
|
|
3
|
+
orderBy,
|
|
4
|
+
limit,
|
|
5
|
+
limitToLast,
|
|
6
|
+
startAfter,
|
|
7
|
+
endAt,
|
|
8
|
+
endBefore,
|
|
9
|
+
type QueryNonFilterConstraint
|
|
10
|
+
} from "@react-native-firebase/firestore";
|
|
2
11
|
import { useMemo } from "react";
|
|
3
12
|
import { AppModel } from "../../types/AppModel";
|
|
4
13
|
import { type NonFilterQueryConstraint } from "../../types/QueryConstraints";
|
|
@@ -35,7 +44,7 @@ export type UseQueryConstraints<AppModelType extends AppModel = AppModel> = {
|
|
|
35
44
|
*/
|
|
36
45
|
export const buildQueryConstraint = <AppModelType extends AppModel = AppModel>(
|
|
37
46
|
constraint: NonFilterQueryConstraint<AppModelType>
|
|
38
|
-
) => {
|
|
47
|
+
): QueryNonFilterConstraint => {
|
|
39
48
|
switch (constraint.type) {
|
|
40
49
|
case "orderBy":
|
|
41
50
|
return orderBy(constraint.fieldPath as string, constraint.directionStr);
|
|
@@ -77,7 +86,7 @@ export const buildQueryConstraint = <AppModelType extends AppModel = AppModel>(
|
|
|
77
86
|
*/
|
|
78
87
|
export const useQueryConstraints = <AppModelType extends AppModel = AppModel>({
|
|
79
88
|
constraints
|
|
80
|
-
}: UseQueryConstraints<AppModelType>) => {
|
|
89
|
+
}: UseQueryConstraints<AppModelType>): QueryNonFilterConstraint[] => {
|
|
81
90
|
return useMemo(() => {
|
|
82
91
|
return constraints.map(buildQueryConstraint);
|
|
83
92
|
}, [constraints]);
|
|
@@ -9,7 +9,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
9
9
|
/**
|
|
10
10
|
* Reqct-query options that must include queryKey and shall not define queryFn
|
|
11
11
|
*/
|
|
12
|
-
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey,
|
|
12
|
+
options: Omit<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryFn"> & Required<Pick<UseReactInfiniteQueryOptions<AppModelType[], Error, InfiniteData<AppModelType[]>, AppModelType[], TQueryKey, QueryNonFilterConstraint>, "queryKey">>;
|
|
13
13
|
/**
|
|
14
14
|
* Reference to a Firestore collection
|
|
15
15
|
*/
|
|
@@ -31,7 +31,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
31
31
|
InfiniteData<AppModelType[]>,
|
|
32
32
|
AppModelType[],
|
|
33
33
|
TQueryKey,
|
|
34
|
-
|
|
34
|
+
QueryNonFilterConstraint
|
|
35
35
|
>,
|
|
36
36
|
"queryFn"
|
|
37
37
|
> &
|
|
@@ -43,7 +43,7 @@ type UseInfiniteQueryOptions<AppModelType extends AppModel = AppModel, TQueryKey
|
|
|
43
43
|
InfiniteData<AppModelType[]>,
|
|
44
44
|
AppModelType[],
|
|
45
45
|
TQueryKey,
|
|
46
|
-
|
|
46
|
+
QueryNonFilterConstraint
|
|
47
47
|
>,
|
|
48
48
|
"queryKey"
|
|
49
49
|
>
|