Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"dependencies": {
"@ai-sdk/svelte": "^1.1.24",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@67539a6",
"@appwrite.io/console": "https://pkg.vc/-/@appwrite/@appwrite.io/console@ef672a3",
"@appwrite.io/pink-icons": "0.25.0",
"@appwrite.io/pink-icons-svelte": "https://pkg.vc/-/@appwrite/@appwrite.io/pink-icons-svelte@bfe7ce3",
"@appwrite.io/pink-legacy": "^1.0.3",
Expand Down
19 changes: 0 additions & 19 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/lib/helpers/faker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ function generateSingleValue(field: Field): string | number | boolean | NestedNu
return faker.number.int({ min, max });
}

case 'bigint': {
return faker.number.bigInt().toString();
}

case 'double': {
const floatAttr = field as Models.ColumnFloat;
const min = isWithinSafeRange(floatAttr.min) ? floatAttr.min : 0;
Expand Down
1 change: 1 addition & 0 deletions src/lib/helpers/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const columnTypes = [
'text',
'mediumtext',
'longtext',
'bigint',
'integer',
'double',
'boolean',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
import { addNotification } from '$lib/stores/notifications';
import { hash } from '$lib/helpers/string';
import { preferences } from '$lib/stores/preferences';
import { buildRowUrl, isRelationship } from './rows/store';
import { buildRowUrl, isRelationship, buildPayload } from './rows/store';
import { chunks } from '$lib/helpers/array';
import { Submit, trackEvent } from '$lib/actions/analytics';

Expand Down Expand Up @@ -346,7 +346,7 @@
databaseId: page.params.database,
tableId: page.params.table,
rowId: row.$id,
data: row
data: buildPayload(columns, row)
})
)
);
Expand All @@ -358,7 +358,7 @@
await tablesSDK.createRows({
databaseId: page.params.database,
tableId: page.params.table,
rows
rows: rows.map((row) => buildPayload(columns, row))
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,15 @@
) {
const stringColumn = column as Models.ColumnString;
return { display: `Size: ${stringColumn.size}` };
} else if (column.type === 'integer' || column.type === 'double') {
const numbersColumn = column as Models.ColumnInteger | Models.ColumnFloat;
} else if (
column.type === 'bigint' ||
column.type === 'integer' ||
column.type === 'double'
) {
const numbersColumn = column as
| Models.ColumnBigint
| Models.ColumnInteger
| Models.ColumnFloat;
const { min, max } = numbersColumn;

const isMinBigInt = typeof min === 'bigint';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
<script module lang="ts">
import { page } from '$app/state';
import { sdk } from '$lib/stores/sdk';
import type { Models } from '@appwrite.io/console';

function normalizeBigInt(value) {
if (value === undefined) return undefined;
if (value === null) return null;
return BigInt(value);
}

export async function submitBigInt(
databaseId: string,
tableId: string,
key: string,
data: Partial<Models.ColumnBigint>
) {
await sdk.forProject(page.params.region, page.params.project).tablesDB.createBigIntColumn({
databaseId,
tableId,
key,
required: data.required,
min: data.min,
max: data.max,
xdefault: normalizeBigInt(data.default),
array: data.array
});
}

export async function updateBigInt(
databaseId: string,
tableId: string,
data: Partial<Models.ColumnBigint>,
originalKey?: string
) {
await sdk.forProject(page.params.region, page.params.project).tablesDB.updateBigIntColumn({
databaseId,
tableId,
key: originalKey,
required: data.required,
xdefault: normalizeBigInt(data.default),
min: data.min,
max: data.max,
newKey: data.key !== originalKey ? data.key : undefined
});
}
</script>

<script lang="ts">
import { Layout } from '@appwrite.io/pink-svelte';
import { InputNumber } from '$lib/elements/forms';
import { createConservative } from '$lib/helpers/stores';
import RequiredArrayCheckboxes from './requiredArrayCheckboxes.svelte';

type Props = {
editing?: boolean;
disabled?: boolean;
data?: Partial<Models.ColumnBigint>;
};

let {
editing = false,
disabled = false,
data = $bindable({
required: false,
min: 0,
max: 0,
default: 0,
array: false
})
}: Props = $props();

let savedDefault = data.default;

function handleDefaultState(hideDefault: boolean) {
if (hideDefault) {
savedDefault = data.default;
data.default = null;
} else {
data.default = savedDefault;
}
}

const {
stores: { required, array },
listen
} = createConservative<Partial<Models.ColumnBigint>>({
required: false,
array: false,
...data
});
$effect(() => {
listen(data);
});

$effect(() => {
handleDefaultState($required || $array);
});
</script>

<Layout.Stack direction="row" gap="s">
<InputNumber
id="min"
label="Min"
{disabled}
placeholder="Enter size"
bind:value={data.min as number}
required={editing} />

<InputNumber
id="max"
label="Max"
{disabled}
placeholder="Enter size"
bind:value={data.max as number}
required={editing} />
</Layout.Stack>

<InputNumber
id="default"
label="Default value"
placeholder="Enter value"
min={data.min as number}
max={data.max as number}
bind:value={data.default as number}
disabled={data.required || data.array || disabled}
nullable={(!data.required && !data.array) || disabled} />

<RequiredArrayCheckboxes
{editing}
{disabled}
bind:array={data.array}
bind:required={data.required} />
Loading
Loading