Skip to content

Commit e3ff5c9

Browse files
committed
use query class
1 parent a593586 commit e3ff5c9

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

lib/commands/pull.ts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -336,10 +336,7 @@ export class Pull {
336336
listDeployments: () =>
337337
functionsService.listDeployments({
338338
functionId: func["$id"],
339-
queries: [
340-
JSON.stringify({ method: "limit", values: [1] }),
341-
JSON.stringify({ method: "orderDesc", values: ["$id"] }),
342-
],
339+
queries: [Query.limit(1), Query.orderDesc("$id")],
343340
}),
344341
getDownloadUrl: (deploymentId) =>
345342
functionsService.getDeploymentDownload({
@@ -421,10 +418,7 @@ export class Pull {
421418
listDeployments: () =>
422419
sitesService.listDeployments({
423420
siteId: site["$id"],
424-
queries: [
425-
JSON.stringify({ method: "limit", values: [1] }),
426-
JSON.stringify({ method: "orderDesc", values: ["$id"] }),
427-
],
421+
queries: [Query.limit(1), Query.orderDesc("$id")],
428422
}),
429423
getDownloadUrl: (deploymentId) =>
430424
sitesService.getDeploymentDownload({
@@ -450,9 +444,7 @@ export class Pull {
450444
}> {
451445
const databasesService = new Databases(this.projectClient);
452446

453-
const fetchResponse = await databasesService.list([
454-
JSON.stringify({ method: "limit", values: [1] }),
455-
]);
447+
const fetchResponse = await databasesService.list([Query.limit(1)]);
456448

457449
if (fetchResponse["databases"].length <= 0) {
458450
return { databases: [], collections: [] };
@@ -504,7 +496,7 @@ export class Pull {
504496
const tablesDBService = new TablesDB(this.projectClient);
505497

506498
const fetchResponse = await tablesDBService.list({
507-
queries: [JSON.stringify({ method: "limit", values: [1] })],
499+
queries: [Query.limit(1)],
508500
});
509501

510502
if (fetchResponse["databases"].length <= 0) {
@@ -553,7 +545,7 @@ export class Pull {
553545
const storageService = new Storage(this.projectClient);
554546

555547
const fetchResponse = await storageService.listBuckets({
556-
queries: [JSON.stringify({ method: "limit", values: [1] })],
548+
queries: [Query.limit(1)],
557549
});
558550

559551
if (fetchResponse["buckets"].length <= 0) {
@@ -577,7 +569,7 @@ export class Pull {
577569
const teamsService = new Teams(this.projectClient);
578570

579571
const fetchResponse = await teamsService.list({
580-
queries: [JSON.stringify({ method: "limit", values: [1] })],
572+
queries: [Query.limit(1)],
581573
});
582574

583575
if (fetchResponse["teams"].length <= 0) {
@@ -601,7 +593,7 @@ export class Pull {
601593
const messagingService = new Messaging(this.projectClient);
602594

603595
const fetchResponse = await messagingService.listTopics({
604-
queries: [JSON.stringify({ method: "limit", values: [1] })],
596+
queries: [Query.limit(1)],
605597
});
606598

607599
if (fetchResponse["topics"].length <= 0) {
@@ -689,9 +681,7 @@ const pullFunctions = async ({
689681
log("Fetching functions ...");
690682

691683
const functionsService = await getFunctionsService();
692-
const fetchResponse = await functionsService.list([
693-
JSON.stringify({ method: "limit", values: [1] }),
694-
]);
684+
const fetchResponse = await functionsService.list([Query.limit(1)]);
695685
if (fetchResponse["functions"].length <= 0) {
696686
log("No functions found.");
697687
success(`Successfully pulled ${chalk.bold(0)} functions.`);
@@ -747,7 +737,7 @@ const pullSites = async ({
747737

748738
const sitesService = await getSitesService();
749739
const fetchResponse = await sitesService.list({
750-
queries: [JSON.stringify({ method: "limit", values: [1] })],
740+
queries: [Query.limit(1)],
751741
});
752742
if (fetchResponse["sites"].length <= 0) {
753743
log("No sites found.");
@@ -804,7 +794,7 @@ const pullCollection = async (): Promise<void> => {
804794

805795
const databasesService = await getDatabasesService();
806796
const fetchResponse = await databasesService.list({
807-
queries: [JSON.stringify({ method: "limit", values: [1] })],
797+
queries: [Query.limit(1)],
808798
});
809799
if (fetchResponse["databases"].length <= 0) {
810800
log("No collections found.");
@@ -838,7 +828,7 @@ const pullTable = async (): Promise<void> => {
838828

839829
const tablesDBService = await getTablesDBService();
840830
const fetchResponse = await tablesDBService.list({
841-
queries: [JSON.stringify({ method: "limit", values: [1] })],
831+
queries: [Query.limit(1)],
842832
});
843833
if (fetchResponse["databases"].length <= 0) {
844834
log("No tables found.");

0 commit comments

Comments
 (0)