fix: outdated sdk call

This commit is contained in:
Arman
2023-03-20 14:40:11 +01:00
parent 1f236dffe7
commit ac90a4482c
13 changed files with 23 additions and 24 deletions
+4 -5
View File
@@ -1,9 +1,8 @@
import { page } from '$app/stores';
import { derived, get } from 'svelte/store';
import { derived } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
import { sdkForConsole } from './sdk';
import { sdk } from './sdk';
import { cachedStore } from '$lib/helpers/cache';
import { browser } from '$app/environment';
export const user = derived(
page,
@@ -18,11 +17,11 @@ export const prefs = cachedStore<
}
>('prefs', (store) => ({
load: async () => {
const prefs = await sdkForConsole.account.getPrefs();
const prefs = await sdk.forConsole.account.getPrefs();
store.set(prefs);
},
updatePrefs: async (prefs: Models.Preferences) => {
await sdkForConsole.account.updatePrefs(prefs);
await sdk.forConsole.account.updatePrefs(prefs);
store.set(prefs);
}
}));
@@ -23,7 +23,7 @@
data: Partial<Models.AttributeBoolean>
) {
await sdkForProject.databases.createBooleanAttribute(
await sdk.forProject.databases.createBooleanAttribute(
databaseId,
collectionId,
data.key,
@@ -23,7 +23,7 @@
collectionId: string,
data: Partial<Models.AttributeDatetime>
) {
await sdkForProject.databases.createDatetimeAttribute(
await sdk.forProject.databases.createDatetimeAttribute(
databaseId,
collectionId,
data.key,
@@ -24,7 +24,7 @@
collectionId: string,
data: Partial<Models.AttributeEmail>
) {
await sdkForProject.databases.createEmailAttribute(
await sdk.forProject.databases.createEmailAttribute(
databaseId,
collectionId,
data.key,
@@ -24,7 +24,7 @@
collectionId: string,
data: Partial<Models.AttributeEnum>
) {
await sdkForProject.databases.createEnumAttribute(
await sdk.forProject.databases.createEnumAttribute(
databaseId,
collectionId,
data.key,
@@ -25,7 +25,7 @@
collectionId: string,
data: Partial<Models.AttributeFloat>
) {
await sdkForProject.databases.createFloatAttribute(
await sdk.forProject.databases.createFloatAttribute(
databaseId,
collectionId,
data.key,
@@ -25,7 +25,7 @@
collectionId: string,
data: Partial<Models.AttributeInteger>
) {
await sdkForProject.databases.createIntegerAttribute(
await sdk.forProject.databases.createIntegerAttribute(
databaseId,
collectionId,
data.key,
@@ -22,7 +22,7 @@
collectionId: string,
data: Partial<Models.AttributeIp>
) {
await sdkForProject.databases.createIpAttribute(
await sdk.forProject.databases.createIpAttribute(
databaseId,
collectionId,
data.key,
@@ -1,6 +1,6 @@
<script context="module" lang="ts">
import { Query, type Models } from '@aw-labs/appwrite-console';
import { sdkForProject } from '$lib/stores/sdk';
import { sdk } from '$lib/stores/sdk';
export async function submitRelationship(
databaseId: string,
@@ -8,7 +8,7 @@
key: string,
data: Partial<Models.AttributeString>
) {
await sdkForProject.databases.createStringAttribute(
await sdk.forProject.databases.createStringAttribute(
databaseId,
collectionId,
key,
@@ -24,7 +24,7 @@
collectionId: string,
data: Partial<Models.AttributeString>
) {
await sdkForProject.databases.createStringAttribute(
await sdk.forProject.databases.createStringAttribute(
databaseId,
collectionId,
data.key,
@@ -90,14 +90,14 @@
// Lifecycle hooks
async function getCollections(search: string = null) {
if (search) {
const collections = await sdkForProject.databases.listCollections(
const collections = await sdk.forProject.databases.listCollections(
databaseId,
[Query.orderDesc('$createdAt')],
search
);
return collections;
} else {
const collections = await sdkForProject.databases.listCollections(databaseId);
const collections = await sdk.forProject.databases.listCollections(databaseId);
return collections;
}
}
@@ -23,7 +23,7 @@
collectionId: string,
data: Partial<Models.AttributeString>
) {
await sdkForProject.databases.createStringAttribute(
await sdk.forProject.databases.createStringAttribute(
databaseId,
collectionId,
data.key,
@@ -23,7 +23,7 @@
collectionId: string,
data: Partial<Models.AttributeUrl>
) {
await sdkForProject.databases.createUrlAttribute(
await sdk.forProject.databases.createUrlAttribute(
databaseId,
collectionId,
data.key,
@@ -1,6 +1,6 @@
<script lang="ts">
import { Button, InputSelectSearch } from '$lib/elements/forms';
import { sdkForProject } from '$lib/stores/sdk';
import { sdk } from '$lib/stores/sdk';
import { Query, type Models } from '@aw-labs/appwrite-console';
import { onMount } from 'svelte';
@@ -20,14 +20,14 @@
async function getCollections(search: string = null) {
if (search) {
const collections = await sdkForProject.databases.listCollections(
const collections = await sdk.forProject.databases.listCollections(
attribute.related,
[Query.orderDesc('$createdAt')],
search
);
return collections;
} else {
const collections = await sdkForProject.databases.listCollections(attribute.related);
const collections = await sdk.forProject.databases.listCollections(attribute.related);
return collections;
}
}
@@ -2,7 +2,7 @@
import { Button } from '$lib/elements/forms';
import { CardGrid, Heading } from '$lib/components';
import { page } from '$app/stores';
import { sdkForProject } from '$lib/stores/sdk';
import { sdk } from '$lib/stores/sdk';
import { addNotification } from '$lib/stores/notifications';
import { writable } from 'svelte/store';
import type { Models } from '@aw-labs/appwrite-console';
@@ -39,7 +39,7 @@
async function updateData() {
try {
await sdkForProject.databases.updateDocument(
await sdk.forProject.databases.updateDocument(
databaseId,
collectionId,
documentId,