Skip to content

Commit

Permalink
Make lookupFromUrl use index again
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Jun 23, 2021
1 parent 5ac28a9 commit 0d07550
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions oada/libs/oada-lib-arangodb/src/libs/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,11 @@ export async function lookupFromUrl(
// Create a filter for each segment of the url
let filters = aql``;
for (const [i, urlPiece] of Object.entries(pieces)) {
// Need to be sure `i` is a number and not a string
// otherwise indexes don't work...
filters = aql`
${filters}
FILTER p.edges[${i}].name == ${urlPiece} || p.edges[${i}].name == null`;
FILTER p.edges[${+i}].name == ${urlPiece} || p.edges[${+i}].name == null`;
}
const query = aql`
WITH ${edges}, ${graphNodes}
Expand Down Expand Up @@ -323,7 +325,9 @@ export async function getResourceOwnerIdRev(
); // Treat non-existing path has not-found
}

export async function getParents(id: string): Promise<Array<{
export async function getParents(
id: string
): Promise<Array<{
resource_id: string;
path: string;
contentType: string;
Expand Down

0 comments on commit 0d07550

Please sign in to comment.