diff --git a/client/components/DatabaseDetail.vue b/client/components/DatabaseDetail.vue index 021a58f..bf99cf9 100644 --- a/client/components/DatabaseDetail.vue +++ b/client/components/DatabaseDetail.vue @@ -6,8 +6,19 @@ const props = defineProps({ }, }) +// TODO: save in local storage +const pagination = reactive({ limit: 20, page: 1 }) + +const countDocuments = computedAsync(async () => { + return await rpc.countDocuments(props.collection) +}) + const documents = computedAsync(async () => { - return await rpc.listDocuments(props.collection) + return await rpc.listDocuments(props.collection, pagination) +}) + +watch(pagination, async () => { + documents.value = await rpc.listDocuments(props.collection, pagination) }) const schema = computedAsync(async () => { @@ -71,7 +82,7 @@ async function saveDocument(document: any) { await rpc.createDocument(props.collection, document) editing.value = false selectedDocument.value = undefined - documents.value = await rpc.listDocuments(props.collection) + documents.value = await rpc.listDocuments(props.collection, pagination) } async function updateDocument() { @@ -79,7 +90,7 @@ async function updateDocument() { await rpc.updateDocument(props.collection, selectedDocument.value) editing.value = false selectedDocument.value = undefined - documents.value = await rpc.listDocuments(props.collection) + documents.value = await rpc.listDocuments(props.collection, pagination) } function discardEditing() { @@ -89,8 +100,10 @@ function discardEditing() { async function deleteDocument(document: any) { rpc.deleteDocument(props.collection, document._id) - documents.value = await rpc.listDocuments(props.collection) + documents.value = await rpc.listDocuments(props.collection, pagination) } + +const copy = useCopy() -
- {{ filtered.length }} matched · - {{ documents?.length }} documents in total +
+
+ {{ filtered.length }} matched · + {{ documents?.length }} of {{ countDocuments }} documents in total +
+
+
+ + + + + + + +
@@ -118,7 +151,6 @@ async function deleteDocument(document: any) { -