Skip to content

Commit

Permalink
fix: simplify query
Browse files Browse the repository at this point in the history
  • Loading branch information
Roger Torres committed Aug 31, 2023
1 parent 1a190a4 commit 0c1b0f4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
8 changes: 4 additions & 4 deletions libs/eventually-aws/src/__tests__/lambda.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ describe("lambda", () => {
null,
{},
{
queryStringParameters: { where: "b" },
multiValueQueryStringParameters: {}
queryStringParameters: {},
multiValueQueryStringParameters: { where: ["b"] }
}
)
);
Expand Down Expand Up @@ -208,8 +208,8 @@ describe("lambda", () => {
null,
{},
{
queryStringParameters: { sort: "id" },
multiValueQueryStringParameters: {}
queryStringParameters: {},
multiValueQueryStringParameters: { sort: ["id"] }
}
)
);
Expand Down
19 changes: 7 additions & 12 deletions libs/eventually-aws/src/lambda/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,14 @@ export const query = async (
type: md.type
});

const { ids, select, where, sort, limit } =
event.queryStringParameters ?? {};
const {
ids: mids,
select: mselect,
where: mwhere,
sort: msort
} = event.multiValueQueryStringParameters ?? {};
const { limit } = event.queryStringParameters ?? {};
const { ids, select, where, sort } =
event.multiValueQueryStringParameters ?? {};
const query: RestProjectionQuery = {
ids: mids ?? (ids ? [ids] : undefined),
select: mselect ?? (select ? [select] : undefined),
where: mwhere ?? (where ? [where] : undefined),
sort: msort ?? (sort ? [sort] : undefined),
ids,
select,
where,
sort,
limit: limit ? +limit : undefined
};

Expand Down

0 comments on commit 0c1b0f4

Please sign in to comment.