Skip to content

Commit 79982dc

Browse files
author
meow12
authored
fix(database): pass database to api (#106)
pass database to api
1 parent 372351d commit 79982dc

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

src/components/db.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function getRecords({
2121
addReferencesFirst,
2222
excludeCulture,
2323
cluster,
24+
database,
2425
}) {
2526
const response = await server.loadJson(
2627
`${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.GET_ALL(
@@ -31,6 +32,7 @@ export async function getRecords({
3132
headers: {
3233
'X-CM-ProjectId': Config.projectId,
3334
'X-CM-Cluster': cluster,
35+
'X-CM-Database': database,
3436
Authorization: `Bearer ${secretKey || Config.secretKey}`,
3537
Accept: 'application/json',
3638
'Content-Type': 'application/json',
@@ -74,6 +76,7 @@ export async function getRecord({
7476
excludeCulture,
7577
language,
7678
cluster,
79+
database,
7780
}) {
7881
const response = await server.loadJson(
7982
`${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.GET(
@@ -85,6 +88,7 @@ export async function getRecord({
8588
headers: {
8689
'X-CM-ProjectId': Config.projectId,
8790
'X-CM-Cluster': cluster,
91+
'X-CM-Database': database,
8892
Authorization: `Bearer ${secretKey || Config.secretKey}`,
8993
Accept: 'application/json',
9094
'Content-Type': 'application/json',
@@ -120,6 +124,7 @@ export async function getRecordWithFilter({
120124
excludeCulture,
121125
language,
122126
cluster,
127+
database,
123128
}) {
124129
const response = await server.loadJson(
125130
`${
@@ -132,6 +137,7 @@ export async function getRecordWithFilter({
132137
headers: {
133138
'X-CM-ProjectId': Config.projectId,
134139
'X-CM-Cluster': cluster,
140+
'X-CM-Database': database,
135141
Authorization: `Bearer ${secretKey || Config.secretKey}`,
136142
Accept: 'application/json',
137143
'Content-Type': 'application/json',
@@ -160,6 +166,7 @@ export async function deleteRecord({
160166
id,
161167
ignoreTriggers,
162168
cluster,
169+
database,
163170
}) {
164171
let url = `${
165172
Config.apiUrl
@@ -176,6 +183,7 @@ export async function deleteRecord({
176183
headers: {
177184
'X-CM-ProjectId': Config.projectId,
178185
'X-CM-Cluster': cluster,
186+
'X-CM-Database': database,
179187
Authorization: `Bearer ${secretKey || Config.secretKey}`,
180188
Accept: 'application/json',
181189
'Content-Type': 'application/json',
@@ -192,6 +200,7 @@ export async function deleteRecordWithFilter({
192200
filter,
193201
ignoreTriggers,
194202
cluster,
203+
database,
195204
}) {
196205
let url = `${
197206
Config.apiUrl
@@ -211,6 +220,7 @@ export async function deleteRecordWithFilter({
211220
headers: {
212221
'X-CM-ProjectId': Config.projectId,
213222
'X-CM-Cluster': cluster,
223+
'X-CM-Database': database,
214224
Authorization: `Bearer ${secretKey || Config.secretKey}`,
215225
Accept: 'application/json',
216226
'Content-Type': 'application/json',
@@ -227,6 +237,7 @@ export async function deleteManyRecords({
227237
filter,
228238
ignoreTriggers,
229239
cluster,
240+
database,
230241
}) {
231242
let url = `${
232243
Config.apiUrl
@@ -244,6 +255,7 @@ export async function deleteManyRecords({
244255
headers: {
245256
'X-CM-ProjectId': Config.projectId,
246257
'X-CM-Cluster': cluster,
258+
'X-CM-Database': database,
247259
Authorization: `Bearer ${secretKey || Config.secretKey}`,
248260
Accept: 'application/json',
249261
'Content-Type': 'application/json',
@@ -262,6 +274,7 @@ export async function insertRecord({
262274
waitForFileUpload,
263275
ignoreTriggers,
264276
cluster,
277+
database,
265278
resolveProviderFiles,
266279
responsibleUserId,
267280
}) {
@@ -274,6 +287,7 @@ export async function insertRecord({
274287
headers: {
275288
'X-CM-ProjectId': Config.projectId,
276289
'X-CM-Cluster': cluster,
290+
'X-CM-Database': database,
277291
Authorization: `Bearer ${secretKey || Config.secretKey}`,
278292
Accept: 'application/json',
279293
'Content-Type': 'application/json',
@@ -299,6 +313,7 @@ export async function insertManyRecords({
299313
bypassDocumentValidation,
300314
ignoreTriggers,
301315
cluster,
316+
database,
302317
resolveProviderFiles,
303318
responsibleUserId,
304319
}) {
@@ -318,6 +333,7 @@ export async function insertManyRecords({
318333
headers: {
319334
'X-CM-ProjectId': Config.projectId,
320335
'X-CM-Cluster': cluster,
336+
'X-CM-Database': database,
321337
Authorization: `Bearer ${secretKey || Config.secretKey}`,
322338
Accept: 'application/json',
323339
'Content-Type': 'application/json',
@@ -344,6 +360,7 @@ export async function updateRecord({
344360
bypassDocumentValidation,
345361
ignoreTriggers,
346362
cluster,
363+
database,
347364
resolveProviderFiles,
348365
}) {
349366
const response = await server.loadJson(
@@ -356,6 +373,7 @@ export async function updateRecord({
356373
headers: {
357374
'X-CM-ProjectId': Config.projectId,
358375
'X-CM-Cluster': cluster,
376+
'X-CM-Database': database,
359377
Authorization: `Bearer ${secretKey || Config.secretKey}`,
360378
Accept: 'application/json',
361379
'Content-Type': 'application/json',
@@ -382,6 +400,7 @@ export async function updateRecordWithFilter({
382400
bypassDocumentValidation,
383401
ignoreTriggers,
384402
cluster,
403+
database,
385404
resolveProviderFiles,
386405
}) {
387406
const response = await server.loadJson(
@@ -395,6 +414,7 @@ export async function updateRecordWithFilter({
395414
headers: {
396415
'X-CM-ProjectId': Config.projectId,
397416
'X-CM-Cluster': cluster,
417+
'X-CM-Database': database,
398418
Authorization: `Bearer ${secretKey || Config.secretKey}`,
399419
Accept: 'application/json',
400420
'Content-Type': 'application/json',
@@ -421,6 +441,7 @@ export async function updateManyRecords({
421441
bypassDocumentValidation,
422442
ignoreTriggers,
423443
cluster,
444+
database,
424445
resolveProviderFiles,
425446
}) {
426447
const response = await server.loadJson(
@@ -432,6 +453,7 @@ export async function updateManyRecords({
432453
headers: {
433454
'X-CM-ProjectId': Config.projectId,
434455
'X-CM-Cluster': cluster,
456+
'X-CM-Database': database,
435457
Authorization: `Bearer ${secretKey || Config.secretKey}`,
436458
Accept: 'application/json',
437459
'Content-Type': 'application/json',
@@ -459,6 +481,7 @@ export async function replaceRecord({
459481
ignoreTriggers,
460482
isUpsert,
461483
cluster,
484+
database,
462485
resolveProviderFiles,
463486
}) {
464487
const response = await server.loadJson(
@@ -470,6 +493,7 @@ export async function replaceRecord({
470493
headers: {
471494
'X-CM-ProjectId': Config.projectId,
472495
'X-CM-Cluster': cluster,
496+
'X-CM-Database': database,
473497
Authorization: `Bearer ${secretKey || Config.secretKey}`,
474498
Accept: 'application/json',
475499
'Content-Type': 'application/json',
@@ -499,6 +523,7 @@ export async function replaceRecordWithFilter({
499523
ignoreTriggers,
500524
isUpsert,
501525
cluster,
526+
database,
502527
resolveProviderFiles,
503528
}) {
504529
const response = await server.loadJson(
@@ -510,6 +535,7 @@ export async function replaceRecordWithFilter({
510535
headers: {
511536
'X-CM-ProjectId': Config.projectId,
512537
'X-CM-Cluster': cluster,
538+
'X-CM-Database': database,
513539
Authorization: `Bearer ${secretKey || Config.secretKey}`,
514540
Accept: 'application/json',
515541
'Content-Type': 'application/json',
@@ -535,6 +561,7 @@ export async function executeAggregate({
535561
id,
536562
tokens,
537563
cluster,
564+
database,
538565
}) {
539566
const url = `${
540567
Config.apiUrl
@@ -545,6 +572,7 @@ export async function executeAggregate({
545572
headers: {
546573
'X-CM-ProjectId': Config.projectId,
547574
'X-CM-Cluster': cluster,
575+
'X-CM-Database': database,
548576
Authorization: `Bearer ${secretKey || Config.secretKey}`,
549577
Accept: 'application/json',
550578
'Content-Type': 'application/json',
@@ -564,6 +592,7 @@ export async function count({
564592
limit,
565593
skip,
566594
cluster,
595+
database,
567596
}) {
568597
const response = await server.loadJson(
569598
`${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.COUNT(
@@ -574,6 +603,7 @@ export async function count({
574603
headers: {
575604
'X-CM-ProjectId': Config.projectId,
576605
'X-CM-Cluster': cluster,
606+
'X-CM-Database': database,
577607
Authorization: `Bearer ${secretKey || Config.secretKey}`,
578608
Accept: 'application/json',
579609
'Content-Type': 'application/json',
@@ -595,6 +625,7 @@ export async function distinct({
595625
filter,
596626
field,
597627
cluster,
628+
database,
598629
}) {
599630
const response = await server.loadJson(
600631
`${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.DISTINCT(
@@ -605,6 +636,7 @@ export async function distinct({
605636
headers: {
606637
'X-CM-ProjectId': Config.projectId,
607638
'X-CM-Cluster': cluster,
639+
'X-CM-Database': database,
608640
Authorization: `Bearer ${secretKey || Config.secretKey}`,
609641
Accept: 'application/json',
610642
'Content-Type': 'application/json',
@@ -630,6 +662,7 @@ export async function getTerms({
630662
projection,
631663
excludeCulture,
632664
cluster,
665+
database,
633666
}) {
634667
const response = await server.loadJson(
635668
`${Config.apiUrl}${Endpoints.PROJECT.DATABASE.TAXONOMY.TERM.GET_ALL(
@@ -640,6 +673,7 @@ export async function getTerms({
640673
headers: {
641674
'X-CM-ProjectId': Config.projectId,
642675
'X-CM-Cluster': cluster,
676+
'X-CM-Database': database,
643677
Authorization: `Bearer ${secretKey || Config.secretKey}`,
644678
Accept: 'application/json',
645679
'Content-Type': 'application/json',
@@ -673,6 +707,7 @@ export async function getChildrenOfTerms({
673707
projection,
674708
excludeCulture,
675709
cluster,
710+
database,
676711
}) {
677712
const response = await server.loadJson(
678713
`${Config.apiUrl}${Endpoints.PROJECT.DATABASE.TAXONOMY.TERM.GET_CHILDREN(
@@ -683,6 +718,7 @@ export async function getChildrenOfTerms({
683718
headers: {
684719
'X-CM-ProjectId': Config.projectId,
685720
'X-CM-Cluster': cluster,
721+
'X-CM-Database': database,
686722
Authorization: `Bearer ${Config.secretKey}`,
687723
Accept: 'application/json',
688724
'Content-Type': 'application/json',
@@ -712,6 +748,7 @@ export async function changeResponsibility({
712748
id,
713749
newResponsibleUserId,
714750
cluster,
751+
database,
715752
}) {
716753
const response = await server.loadJson(
717754
`${
@@ -724,6 +761,7 @@ export async function changeResponsibility({
724761
headers: {
725762
'X-CM-ProjectId': Config.projectId,
726763
'X-CM-Cluster': cluster,
764+
'X-CM-Database': database,
727765
Authorization: `Bearer ${secretKey || Config.secretKey}`,
728766
Accept: 'application/json',
729767
'Content-Type': 'application/json',

src/components/files.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ export async function uploadRecordFile({
137137
recordId,
138138
uniqueFieldName,
139139
cluster,
140+
database,
140141
}) {
141142
if (base64) {
142143
const response = await server.loadJson(
@@ -155,6 +156,7 @@ export async function uploadRecordFile({
155156
recordId,
156157
uniqueFieldName,
157158
cluster,
159+
database,
158160
base64File: {data: base64, contentType: fileType, fileName},
159161
}),
160162
}
@@ -195,6 +197,7 @@ export async function uploadRecordFile({
195197
'X-CM-ProjectId': Config.projectId,
196198
Authorization: `Bearer ${secretKey || Config.secretKey}`,
197199
'X-CM-Cluster': cluster || '',
200+
'X-CM-Database': database || '',
198201
},
199202
body: formData,
200203
}

src/components/payments.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ export async function getOrders({
3535
userId,
3636
includePaidTransactions,
3737
cluster,
38+
database,
3839
}) {
3940
const request = {
4041
userId,
4142
includePaidTransactions,
4243
cluster,
44+
database,
4345
pageSize: pageSize || Config.tablePageSize,
4446
pageNumber: pageNumber || 0,
4547
filter: objectOrStringToString(filter),

0 commit comments

Comments
 (0)