Skip to content

Commit

Permalink
Revert "Revert "refactor: bug fix related to indexing""
Browse files Browse the repository at this point in the history
This reverts commit 3702434.
  • Loading branch information
Pratap2018 committed Apr 27, 2024
1 parent 3702434 commit 91deec4
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions src/user-vault/services/user-vault.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,34 @@ export class UserVaultService {

// await this.documentRepository.connectDB(documentVaultId);







const documents = flag ? await (async () => {
const equalsDbQuery = [];

query.equals?.forEach((e) => {
equalsDbQuery.push({
'indexed.attributes.name': Object.keys(e)[0],
'indexed.attributes.value': Object.values(e)[0],
});
});

const name = Object.keys(query.equals[0])
const value = Object.values(query.equals[0])
return await this.documentRepository.queryDocuments({
'indexed.attributes.name': name[0],
'indexed.attributes.value': value[0]
})
return await this.documentRepository.queryDocuments({
$and: equalsDbQuery,
});
})()
: await this.documentRepository.queryDocuments(
{
'indexed.attributes.name': query.has[0]
}
);
: await (async () => {
const hasDbQuery = [];

query.has?.forEach((e) => {
hasDbQuery.push({
'indexed.attributes.name': e,
});
});

// await this.documentRepository.disconnectDB();
return await this.documentRepository.queryDocuments({
$and: hasDbQuery,
});
})();


return documents as unknown as Array<DocumentResponseDTO>;

Expand Down

0 comments on commit 91deec4

Please sign in to comment.