fix: some minor stuff in database

This commit is contained in:
Torsten Dittmann committed 2022-09-15 12:51:04 +02:00
1 parent 25d205d0af
commit f157c4bd80
9 files changed
+26 -20

No files matched your search

File renamed without changes.
+6 -1
View File
@@ -19,7 +19,12 @@ clientConsole.setEndpoint(endpoint).setProject('console');
const clientProject = new Client();
clientProject.setEndpoint(endpoint).setMode('admin');
const setProject = (projectId: string): Client => clientProject.setProject(projectId);
const setProject = (projectId: string): Client => {
clientProject.setProject(projectId);
console.log(clientProject.config.project);
return clientProject;
};
const sdkForConsole = {
client: clientConsole,
@@ -1,7 +1,7 @@
<script lang="ts">
import { browser } from '$app/env';
import { page } from '$app/stores';
import { sdkForConsole, setProject } from '$lib/stores/sdk';
import { sdkForConsole, sdkForProject, setProject } from '$lib/stores/sdk';
import { collection } from './databases/database/[database]/collection/[collection]/store';
import { UploadBox } from '$lib/components';
import { project } from './store';
@@ -49,8 +49,10 @@
let loaded = false;
async function handle(event = null) {
if ($project?.$id !== projectId) {
if (sdkForProject.client.config.project !== projectId) {
setProject(projectId);
}
if ($project?.$id !== projectId) {
await project.load(projectId);
if ($organization?.$id !== $project?.teamId) {
await organization.load($project.teamId);
@@ -7,9 +7,10 @@
import { database } from './store';
const databaseId = $page.params.database;
const path = `databases/database/${databaseId}`;
let loaded = false;
onMount(handle);
afterNavigate(handle);
@@ -46,6 +47,7 @@
}
]
});
loaded = true;
}
</script>
@@ -53,6 +55,6 @@
<title>Appwrite - Database</title>
</svelte:head>
{#if $database && $database.$id === databaseId}
{#if loaded}
<slot />
{/if}
@@ -4,7 +4,7 @@
import { page } from '$app/stores';
import { updateLayout } from '$lib/stores/layout';
import { onMount } from 'svelte';
import { collection, documentList } from './store';
import { collection } from './store';
const databaseId = $page.params.database;
const collectionId = $page.params.collection;
@@ -18,9 +18,7 @@
if ($collection?.$id !== collectionId) {
await collection.load(databaseId, collectionId);
}
if ($collection) {
await documentList.load(databaseId, $collection.$id, [], 12, 0);
}
updateLayout({
navigate: event,
title: $collection.name,
@@ -60,6 +58,6 @@
<title>Appwrite - {$collection?.name ?? 'Collection'}</title>
</svelte:head>
{#if $collection && $documentList}
{#if $collection}
<slot />
{/if}
@@ -11,10 +11,13 @@
let currentDoc: string;
let disableUpdate = true;
const databaseId = $page.params.database;
const collectionId = $page.params.collection;
const documentId = $page.params.document;
onMount(async () => {
await doc.load(databaseId, $collection.$id, $page.params.document);
await doc.load(databaseId, collectionId, documentId);
currentDoc = JSON.stringify($doc);
});
@@ -30,8 +33,8 @@
try {
await sdkForProject.databases.updateDocument(
databaseId,
$collection.$id,
$page.params.document,
collectionId,
documentId,
$doc,
$doc.$read,
$doc.$write
@@ -8,7 +8,7 @@
import { toLocaleDateTime } from '$lib/helpers/date';
import Document from './_document.svelte';
import Delete from './_delete.svelte';
import { difference } from '$lib/helpers/arrayComparison';
import { difference } from '$lib/helpers/array';
import { page } from '$app/stores';
let showDelete = false;
@@ -14,7 +14,6 @@
import { Container } from '$lib/layout';
import { Button } from '$lib/elements/forms';
import { base } from '$app/paths';
import { onMount } from 'svelte';
import Create from './_create.svelte';
let offset = 0;
@@ -24,10 +23,7 @@
const projectId = $page.params.project;
const databaseId = $page.params.database;
onMount(async () => {
await documentList.load(databaseId, $collection.$id, [], limit, offset);
});
$: documentList.load(databaseId, $collection.$id, [], limit, offset);
$: columns = [
...$collection.attributes.map((attribute) => ({
key: attribute.key,
@@ -9,7 +9,7 @@
import Delete from './_delete.svelte';
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { difference } from '$lib/helpers/arrayComparison';
import { difference } from '$lib/helpers/array';
const databaseId = $page.params.database;