react-query-firebase 2.0.0-rc8 → 2.0.0

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 CHANGED
@@ -73,5 +73,5 @@
73
73
  "docs:build": "vitepress build docs",
74
74
  "docs:preview": "vitepress preview docs"
75
75
  },
76
- "version": "2.0.0-rc8"
76
+ "version": "2.0.0"
77
77
  }
@@ -9,19 +9,15 @@ import { useMemo } from "react";
9
9
  */
10
10
  const buildCompositeQuery = (query) => {
11
11
  if (query.children) {
12
- const queryConstraints = query.children
13
- .map((subQuery) => {
14
- if (subQuery.field && subQuery.op) {
15
- return where(query.field === "documentId" ? firebase.FieldPath.documentId() : query.field, subQuery.op, query.value);
16
- }
17
- return buildCompositeQuery(subQuery);
18
- })
19
- .filter((constraint) => !!constraint);
12
+ const queryConstraints = query.children.map(buildCompositeQuery).filter((constraint) => !!constraint);
20
13
  if (queryConstraints.length <= 0) {
21
14
  return null;
22
15
  }
23
16
  return query.operator === "OR" ? or(...queryConstraints) : and(...queryConstraints);
24
17
  }
18
+ if (query.field && query.op) {
19
+ return where(query.field === "documentId" ? firebase.FieldPath.documentId() : query.field, query.op, query.value);
20
+ }
25
21
  return null;
26
22
  };
27
23
  /**
@@ -30,20 +30,9 @@ export type UseCompositeFilter<DbModelType extends CompositeFilterDocumentData =
30
30
 
31
31
  const buildCompositeQuery = <DbModelType extends CompositeFilterDocumentData = CompositeFilterDocumentData>(
32
32
  query: QueryElement<DbModelType>
33
- ): FirebaseFirestoreTypes.QueryFieldFilterConstraint | FirebaseFirestoreTypes.QueryCompositeFilterConstraint | null => {
33
+ ): FirebaseFirestoreTypes.QueryFilterConstraint | null => {
34
34
  if (query.children) {
35
- const queryConstraints = query.children
36
- .map((subQuery) => {
37
- if (subQuery.field && subQuery.op) {
38
- return where(
39
- query.field === "documentId" ? firebase.FieldPath.documentId() : (query.field as string),
40
- subQuery.op,
41
- query.value
42
- );
43
- }
44
- return buildCompositeQuery(subQuery);
45
- })
46
- .filter((constraint) => !!constraint);
35
+ const queryConstraints = query.children.map(buildCompositeQuery).filter((constraint) => !!constraint);
47
36
 
48
37
  if (queryConstraints.length <= 0) {
49
38
  return null;
@@ -52,6 +41,14 @@ const buildCompositeQuery = <DbModelType extends CompositeFilterDocumentData = C
52
41
  return (query as CompositeFilter).operator === "OR" ? or(...queryConstraints) : and(...queryConstraints);
53
42
  }
54
43
 
44
+ if (query.field && query.op) {
45
+ return where(
46
+ query.field === "documentId" ? firebase.FieldPath.documentId() : (query.field as string),
47
+ query.op,
48
+ query.value
49
+ ) as unknown as FirebaseFirestoreTypes.QueryFilterConstraint;
50
+ }
51
+
55
52
  return null;
56
53
  };
57
54
 
@@ -9,19 +9,15 @@ import { useMemo } from "react";
9
9
  */
10
10
  const buildCompositeQuery = (query) => {
11
11
  if (query.children) {
12
- const queryConstraints = query.children
13
- .map((subQuery) => {
14
- if (subQuery.field && subQuery.op) {
15
- return where(query.field === "documentId" ? documentId() : query.field, subQuery.op, query.value);
16
- }
17
- return buildCompositeQuery(subQuery);
18
- })
19
- .filter((constraint) => !!constraint);
12
+ const queryConstraints = query.children.map(buildCompositeQuery).filter((constraint) => !!constraint);
20
13
  if (queryConstraints.length <= 0) {
21
14
  return null;
22
15
  }
23
16
  return query.operator === "OR" ? or(...queryConstraints) : and(...queryConstraints);
24
17
  }
18
+ if (query.field && query.op) {
19
+ return where(query.field === "documentId" ? documentId() : query.field, query.op, query.value);
20
+ }
25
21
  return null;
26
22
  };
27
23
  /**
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  DocumentData,
3
3
  QueryFilterConstraint,
4
- QueryFieldFilterConstraint,
5
4
  WhereFilterOp,
6
5
  QueryCompositeFilterConstraint,
7
6
  documentId,
@@ -40,20 +39,9 @@ export type UseCompositeFilter<DbModelType extends CompositeFilterDocumentData =
40
39
 
41
40
  const buildCompositeQuery = <DbModelType extends CompositeFilterDocumentData = CompositeFilterDocumentData>(
42
41
  query: QueryElement<DbModelType>
43
- ): QueryFieldFilterConstraint | QueryCompositeFilterConstraint | null => {
42
+ ): QueryFilterConstraint | null => {
44
43
  if (query.children) {
45
- const queryConstraints = query.children
46
- .map((subQuery) => {
47
- if (subQuery.field && subQuery.op) {
48
- return where(
49
- query.field === "documentId" ? documentId() : (query.field as string),
50
- subQuery.op,
51
- query.value
52
- );
53
- }
54
- return buildCompositeQuery(subQuery);
55
- })
56
- .filter((constraint) => !!constraint);
44
+ const queryConstraints = query.children.map(buildCompositeQuery).filter((constraint) => !!constraint);
57
45
 
58
46
  if (queryConstraints.length <= 0) {
59
47
  return null;
@@ -62,6 +50,10 @@ const buildCompositeQuery = <DbModelType extends CompositeFilterDocumentData = C
62
50
  return (query as CompositeFilter).operator === "OR" ? or(...queryConstraints) : and(...queryConstraints);
63
51
  }
64
52
 
53
+ if (query.field && query.op) {
54
+ return where(query.field === "documentId" ? documentId() : (query.field as string), query.op, query.value);
55
+ }
56
+
65
57
  return null;
66
58
  };
67
59