Skip to content

Commit

Permalink
WIP: Ensure related document shows in Console
Browse files Browse the repository at this point in the history
  • Loading branch information
stnguyen90 committed May 18, 2023
1 parent 30f0a3d commit de864c6
Showing 1 changed file with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,39 @@
});
async function getDocuments(search: string = null) {
const documentList = {
total: 0,
documents: []
};
if (value) {
if (isRelationshipToMany(attribute)) {
documentList.documents.concat($doc[attribute.key]);
documentList.total += $doc[attribute.key].length;
} else {
documentList.documents.push($doc[attribute.key]);
documentList.total += 1;
}
}
if (search) {
const documents = await sdk.forProject.databases.listDocuments(
databaseId,
attribute.relatedCollection,
[Query.search('$id', search), Query.orderDesc('$createdAt')]
[`startsWith("$id", "${search}")`, Query.orderDesc('$createdAt')]
);
return documents;
documentList.documents.concat(documents.documents);
documentList.total += documents.total;
} else {
const documents = await sdk.forProject.databases.listDocuments(
databaseId,
attribute.relatedCollection
);
return documents;
documentList.documents.concat(documents.documents);
documentList.total += documents.total;
}
return documentList;
}
//Reactive statements
Expand Down

0 comments on commit de864c6

Please sign in to comment.