Skip to content

Commit

Permalink
chore: refactor for existing passing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Juiced66 committed Sep 20, 2024
1 parent a146d15 commit 09c372f
Show file tree
Hide file tree
Showing 9 changed files with 976 additions and 620 deletions.
299 changes: 173 additions & 126 deletions src/controllers/Auth.ts

Large diffs are not rendered by default.

81 changes: 49 additions & 32 deletions src/controllers/Bulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ export class BulkController extends BaseController {
query: JSONObject = {},
options: ArgsBulkControllerDeleteByQuery = {}
): Promise<number> {
const request = {
const request: any = {
action: "deleteByQuery",
body: query,
collection,
index,
};

if (options.triggerEvents !== undefined) {
request.triggerEvents = options.triggerEvents;
}

return this.query(request, options).then(
(response) => response.result.deleted
);
Expand Down Expand Up @@ -77,15 +81,18 @@ export class BulkController extends BaseController {
};
}>;
}> {
return this.query(
{
action: "import",
body: { bulkData },
collection,
index,
},
options
).then((response) => response.result);
const request: any = {
action: "import",
body: { bulkData },
collection,
index,
};

if (options.triggerEvents !== undefined) {
request.triggerEvents = options.triggerEvents;
}

return this.query(request, options).then((response) => response.result);
}

/**
Expand All @@ -111,13 +118,17 @@ export class BulkController extends BaseController {
changes: JSONObject,
options: ArgsBulkControllerUpdateByQuery = {}
): Promise<number> {
const request = {
const request: any = {
action: "updateByQuery",
body: { changes, query },
collection,
index,
};

if (options.triggerEvents !== undefined) {
request.triggerEvents = options.triggerEvents;
}

return this.query(request, options).then(
(response) => response.result.updated
);
Expand Down Expand Up @@ -148,17 +159,20 @@ export class BulkController extends BaseController {
id?: string,
options: ArgsBulkControllerWrite = {}
): Promise<Document> {
return this.query(
{
_id: id,
action: "write",
body: document,
collection,
index,
notify: options.notify,
},
options
).then((response) => response.result);
const request: any = {
_id: id,
action: "write",
body: document,
collection,
index,
notify: options.notify,
};

if (options.triggerEvents !== undefined) {
request.triggerEvents = options.triggerEvents;
}

return this.query(request, options).then((response) => response.result);
}

/**
Expand Down Expand Up @@ -194,16 +208,19 @@ export class BulkController extends BaseController {
reason: string;
}>;
}> {
return this.query(
{
action: "mWrite",
body: { documents },
collection,
index,
notify: options.notify,
},
options
).then((response) => response.result);
const request: any = {
action: "mWrite",
body: { documents },
collection,
index,
notify: options.notify,
};

if (options.triggerEvents !== undefined) {
request.triggerEvents = options.triggerEvents;
}

return this.query(request, options).then((response) => response.result);
}
}

Expand Down
Loading

0 comments on commit 09c372f

Please sign in to comment.