add: loaded collections to store.

This commit is contained in:
ItzNotABug
2024-08-14 13:58:45 +05:30
parent 8e77586335
commit 5455d4f94e
@@ -3,6 +3,7 @@ import { sdk } from '$lib/stores/sdk';
import { getLimit, getPage, getView, pageToOffset, View } from '$lib/helpers/load';
import type { PageLoad } from './$types';
import { CARD_LIMIT, Dependencies } from '$lib/constants';
import { collections as collectionsStore } from './store';
export const load: PageLoad = async ({ params, url, route, depends }) => {
depends(Dependencies.COLLECTIONS);
@@ -10,15 +11,18 @@ export const load: PageLoad = async ({ params, url, route, depends }) => {
const limit = getLimit(url, route, CARD_LIMIT);
const view = getView(url, route, View.Grid);
const offset = pageToOffset(page, limit);
const collections = await sdk.forProject.databases.listCollections(params.database, [
Query.limit(limit),
Query.offset(offset),
Query.orderDesc('')
]);
collectionsStore.set(collections);
return {
offset,
limit,
view,
collections: await sdk.forProject.databases.listCollections(params.database, [
Query.limit(limit),
Query.offset(offset),
Query.orderDesc('')
])
collections
};
};