|
12 | 12 | - [*SearchProductTitleUsingL2Similarity*](#searchproducttitleusingl2similarity) |
13 | 13 | - [*SearchProductReviewContentUsingL2Similarity*](#searchproductreviewcontentusingl2similarity) |
14 | 14 | - [*GetOrdersByCustomerId*](#getordersbycustomerid) |
15 | | - - [*GetCurrentCustomerOrders*](#getcurrentcustomerorders) |
16 | 15 | - [*GetOrderById*](#getorderbyid) |
17 | 16 | - [**Mutations**](#mutations) |
18 | 17 | - [*UpsertCustomer*](#upsertcustomer) |
@@ -988,124 +987,10 @@ Recall that executing the `GetOrdersByCustomerId` query returns a `QueryPromise` |
988 | 987 | The `data` property is an object of type `GetOrdersByCustomerIdData`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields: |
989 | 988 | ```javascript |
990 | 989 | export interface GetOrdersByCustomerIdData { |
991 | | - orders: ({ |
992 | | - id: UUIDString; |
993 | | - customerId: string; |
994 | | - processedAt: DateString; |
995 | | - chargeId?: string | null; |
996 | | - paymentIntentId?: string | null; |
997 | | - receiptUrl?: string | null; |
998 | | - subtotalPrice: number; |
999 | | - totalPrice: number; |
1000 | | - financialStatus: string; |
1001 | | - fulfillmentStatus: string; |
1002 | | - orderItems_on_order: ({ |
1003 | | - id: UUIDString; |
1004 | | - quantity: number; |
1005 | | - price: number; |
1006 | | - product: { |
1007 | | - id: UUIDString; |
1008 | | - title: string; |
1009 | | - handle: string; |
1010 | | - productImages_on_product: ({ |
1011 | | - url: string; |
1012 | | - altText?: string | null; |
1013 | | - width: number; |
1014 | | - height: number; |
1015 | | - })[]; |
1016 | | - } & Product_Key; |
1017 | | - } & OrderItem_Key)[]; |
1018 | | - } & Order_Key)[]; |
1019 | | -} |
1020 | | -``` |
1021 | | -### Using `GetOrdersByCustomerId`'s action shortcut function |
1022 | | - |
1023 | | -```javascript |
1024 | | -import { getDataConnect, DataConnect } from 'firebase/data-connect'; |
1025 | | -import { connectorConfig, getOrdersByCustomerId, GetOrdersByCustomerIdVariables } from '@firebasegen/default-connector'; |
1026 | | - |
1027 | | -// The `GetOrdersByCustomerId` query requires an argument of type `GetOrdersByCustomerIdVariables`: |
1028 | | -const getOrdersByCustomerIdVars: GetOrdersByCustomerIdVariables = { |
1029 | | - customerId: ..., |
1030 | | -}; |
1031 | | - |
1032 | | -// Call the `getOrdersByCustomerId()` function to execute the query. |
1033 | | -// You can use the `await` keyword to wait for the promise to resolve. |
1034 | | -const { data } = await getOrdersByCustomerId(getOrdersByCustomerIdVars); |
1035 | | -// Variables can be defined inline as well. |
1036 | | -const { data } = await getOrdersByCustomerId({ customerId: ..., }); |
1037 | | - |
1038 | | -// You can also pass in a `DataConnect` instance to the action shortcut function. |
1039 | | -const dataConnect = getDataConnect(connectorConfig); |
1040 | | -const { data } = await getOrdersByCustomerId(dataConnect, getOrdersByCustomerIdVars); |
1041 | | - |
1042 | | -console.log(data.orders); |
1043 | | - |
1044 | | -// Or, you can use the `Promise` API. |
1045 | | -getOrdersByCustomerId(getOrdersByCustomerIdVars).then((response) => { |
1046 | | - const data = response.data; |
1047 | | - console.log(data.orders); |
1048 | | -}); |
1049 | | -``` |
1050 | | - |
1051 | | -### Using `GetOrdersByCustomerId`'s `QueryRef` function |
1052 | | - |
1053 | | -```javascript |
1054 | | -import { getDataConnect, DataConnect, executeQuery } from 'firebase/data-connect'; |
1055 | | -import { connectorConfig, getOrdersByCustomerIdRef, GetOrdersByCustomerIdVariables } from '@firebasegen/default-connector'; |
1056 | | - |
1057 | | -// The `GetOrdersByCustomerId` query requires an argument of type `GetOrdersByCustomerIdVariables`: |
1058 | | -const getOrdersByCustomerIdVars: GetOrdersByCustomerIdVariables = { |
1059 | | - customerId: ..., |
1060 | | -}; |
1061 | | - |
1062 | | -// Call the `getOrdersByCustomerIdRef()` function to get a reference to the query. |
1063 | | -const ref = getOrdersByCustomerIdRef(getOrdersByCustomerIdVars); |
1064 | | -// Variables can be defined inline as well. |
1065 | | -const ref = getOrdersByCustomerIdRef({ customerId: ..., }); |
1066 | | - |
1067 | | -// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
1068 | | -const dataConnect = getDataConnect(connectorConfig); |
1069 | | -const ref = getOrdersByCustomerIdRef(dataConnect, getOrdersByCustomerIdVars); |
1070 | | - |
1071 | | -// Call `executeQuery()` on the reference to execute the query. |
1072 | | -// You can use the `await` keyword to wait for the promise to resolve. |
1073 | | -const { data } = await executeQuery(ref); |
1074 | | - |
1075 | | -console.log(data.orders); |
1076 | | - |
1077 | | -// Or, you can use the `Promise` API. |
1078 | | -executeQuery(ref).then((response) => { |
1079 | | - const data = response.data; |
1080 | | - console.log(data.orders); |
1081 | | -}); |
1082 | | -``` |
1083 | | - |
1084 | | -## GetCurrentCustomerOrders |
1085 | | -You can execute the `GetCurrentCustomerOrders` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [default-connector/index.d.ts](./index.d.ts): |
1086 | | -```javascript |
1087 | | -getCurrentCustomerOrders(): QueryPromise<GetCurrentCustomerOrdersData, undefined>; |
1088 | | - |
1089 | | -getCurrentCustomerOrdersRef(): QueryRef<GetCurrentCustomerOrdersData, undefined>; |
1090 | | -``` |
1091 | | -You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
1092 | | -```javascript |
1093 | | -getCurrentCustomerOrders(dc: DataConnect): QueryPromise<GetCurrentCustomerOrdersData, undefined>; |
1094 | | - |
1095 | | -getCurrentCustomerOrdersRef(dc: DataConnect): QueryRef<GetCurrentCustomerOrdersData, undefined>; |
1096 | | -``` |
1097 | | - |
1098 | | -### Variables |
1099 | | -The `GetCurrentCustomerOrders` query has no variables. |
1100 | | -### Return Type |
1101 | | -Recall that executing the `GetCurrentCustomerOrders` query returns a `QueryPromise` that resolves to an object with a `data` property. |
1102 | | - |
1103 | | -The `data` property is an object of type `GetCurrentCustomerOrdersData`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields: |
1104 | | -```javascript |
1105 | | -export interface GetCurrentCustomerOrdersData { |
1106 | 990 | orders?: { |
1107 | 991 | orders_on_customer: ({ |
1108 | 992 | id: UUIDString; |
| 993 | + customerId: string; |
1109 | 994 | processedAt: DateString; |
1110 | 995 | chargeId?: string | null; |
1111 | 996 | paymentIntentId?: string | null; |
@@ -1134,43 +1019,55 @@ export interface GetCurrentCustomerOrdersData { |
1134 | 1019 | }; |
1135 | 1020 | } |
1136 | 1021 | ``` |
1137 | | -### Using `GetCurrentCustomerOrders`'s action shortcut function |
| 1022 | +### Using `GetOrdersByCustomerId`'s action shortcut function |
1138 | 1023 |
|
1139 | 1024 | ```javascript |
1140 | 1025 | import { getDataConnect, DataConnect } from 'firebase/data-connect'; |
1141 | | -import { connectorConfig, getCurrentCustomerOrders } from '@firebasegen/default-connector'; |
| 1026 | +import { connectorConfig, getOrdersByCustomerId, GetOrdersByCustomerIdVariables } from '@firebasegen/default-connector'; |
1142 | 1027 |
|
| 1028 | +// The `GetOrdersByCustomerId` query requires an argument of type `GetOrdersByCustomerIdVariables`: |
| 1029 | +const getOrdersByCustomerIdVars: GetOrdersByCustomerIdVariables = { |
| 1030 | + customerId: ..., |
| 1031 | +}; |
1143 | 1032 |
|
1144 | | -// Call the `getCurrentCustomerOrders()` function to execute the query. |
| 1033 | +// Call the `getOrdersByCustomerId()` function to execute the query. |
1145 | 1034 | // You can use the `await` keyword to wait for the promise to resolve. |
1146 | | -const { data } = await getCurrentCustomerOrders(); |
| 1035 | +const { data } = await getOrdersByCustomerId(getOrdersByCustomerIdVars); |
| 1036 | +// Variables can be defined inline as well. |
| 1037 | +const { data } = await getOrdersByCustomerId({ customerId: ..., }); |
1147 | 1038 |
|
1148 | 1039 | // You can also pass in a `DataConnect` instance to the action shortcut function. |
1149 | 1040 | const dataConnect = getDataConnect(connectorConfig); |
1150 | | -const { data } = await getCurrentCustomerOrders(dataConnect); |
| 1041 | +const { data } = await getOrdersByCustomerId(dataConnect, getOrdersByCustomerIdVars); |
1151 | 1042 |
|
1152 | 1043 | console.log(data.orders); |
1153 | 1044 |
|
1154 | 1045 | // Or, you can use the `Promise` API. |
1155 | | -getCurrentCustomerOrders().then((response) => { |
| 1046 | +getOrdersByCustomerId(getOrdersByCustomerIdVars).then((response) => { |
1156 | 1047 | const data = response.data; |
1157 | 1048 | console.log(data.orders); |
1158 | 1049 | }); |
1159 | 1050 | ``` |
1160 | 1051 |
|
1161 | | -### Using `GetCurrentCustomerOrders`'s `QueryRef` function |
| 1052 | +### Using `GetOrdersByCustomerId`'s `QueryRef` function |
1162 | 1053 |
|
1163 | 1054 | ```javascript |
1164 | 1055 | import { getDataConnect, DataConnect, executeQuery } from 'firebase/data-connect'; |
1165 | | -import { connectorConfig, getCurrentCustomerOrdersRef } from '@firebasegen/default-connector'; |
| 1056 | +import { connectorConfig, getOrdersByCustomerIdRef, GetOrdersByCustomerIdVariables } from '@firebasegen/default-connector'; |
1166 | 1057 |
|
| 1058 | +// The `GetOrdersByCustomerId` query requires an argument of type `GetOrdersByCustomerIdVariables`: |
| 1059 | +const getOrdersByCustomerIdVars: GetOrdersByCustomerIdVariables = { |
| 1060 | + customerId: ..., |
| 1061 | +}; |
1167 | 1062 |
|
1168 | | -// Call the `getCurrentCustomerOrdersRef()` function to get a reference to the query. |
1169 | | -const ref = getCurrentCustomerOrdersRef(); |
| 1063 | +// Call the `getOrdersByCustomerIdRef()` function to get a reference to the query. |
| 1064 | +const ref = getOrdersByCustomerIdRef(getOrdersByCustomerIdVars); |
| 1065 | +// Variables can be defined inline as well. |
| 1066 | +const ref = getOrdersByCustomerIdRef({ customerId: ..., }); |
1170 | 1067 |
|
1171 | 1068 | // You can also pass in a `DataConnect` instance to the `QueryRef` function. |
1172 | 1069 | const dataConnect = getDataConnect(connectorConfig); |
1173 | | -const ref = getCurrentCustomerOrdersRef(dataConnect); |
| 1070 | +const ref = getOrdersByCustomerIdRef(dataConnect, getOrdersByCustomerIdVars); |
1174 | 1071 |
|
1175 | 1072 | // Call `executeQuery()` on the reference to execute the query. |
1176 | 1073 | // You can use the `await` keyword to wait for the promise to resolve. |
|
0 commit comments