add: load collections if empty.

This commit is contained in:
ItzNotABug
2024-08-14 14:00:38 +05:30
parent 5455d4f94e
commit 35c2babf15
@@ -0,0 +1,17 @@
import { get } from 'svelte/store';
import { Dependencies } from '$lib/constants';
import { collections as collectionsStore } from '../store';
import { sdk } from '$lib/stores/sdk';
export async function load({ depends, params }) {
depends(Dependencies.COLLECTIONS);
let collections = get(collectionsStore);
if (collections.total === 0) {
collections = await sdk.forProject.databases.listCollections(params.database);
collectionsStore.set(collections);
}
return { collections };
}