diff options
author | 2025-06-05 14:25:23 +0000 | |
---|---|---|
committer | 2025-06-05 14:25:23 +0000 | |
commit | e586d7d704d475afe3373a1de6ae20d504f79d6d (patch) | |
tree | 7e3fa24807cebd48a86bd40f866d792181191ee9 /packages/db/test/fixtures/libsql-remote | |
download | astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.gz astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.tar.zst astro-e586d7d704d475afe3373a1de6ae20d504f79d6d.zip |
Sync from a8e1c0a7402940e0fc5beef669522b315052df1blatest
Diffstat (limited to 'packages/db/test/fixtures/libsql-remote')
5 files changed, 55 insertions, 0 deletions
diff --git a/packages/db/test/fixtures/libsql-remote/astro.config.ts b/packages/db/test/fixtures/libsql-remote/astro.config.ts new file mode 100644 index 000000000..983a6947d --- /dev/null +++ b/packages/db/test/fixtures/libsql-remote/astro.config.ts @@ -0,0 +1,10 @@ +import db from '@astrojs/db'; +import { defineConfig } from 'astro/config'; + +// https://astro.build/config +export default defineConfig({ + integrations: [db()], + devToolbar: { + enabled: false, + }, +}); diff --git a/packages/db/test/fixtures/libsql-remote/db/config.ts b/packages/db/test/fixtures/libsql-remote/db/config.ts new file mode 100644 index 000000000..44c15abe7 --- /dev/null +++ b/packages/db/test/fixtures/libsql-remote/db/config.ts @@ -0,0 +1,13 @@ +import { column, defineDb, defineTable } from 'astro:db'; + +const User = defineTable({ + columns: { + id: column.text({ primaryKey: true, optional: false }), + username: column.text({ optional: false, unique: true }), + password: column.text({ optional: false }), + }, +}); + +export default defineDb({ + tables: { User }, +}); diff --git a/packages/db/test/fixtures/libsql-remote/db/seed.ts b/packages/db/test/fixtures/libsql-remote/db/seed.ts new file mode 100644 index 000000000..7d9aa3292 --- /dev/null +++ b/packages/db/test/fixtures/libsql-remote/db/seed.ts @@ -0,0 +1,7 @@ +import { User, db } from 'astro:db'; + +export default async function () { + await db.batch([ + db.insert(User).values([{ id: 'mario', username: 'Mario', password: 'itsame' }]), + ]); +} diff --git a/packages/db/test/fixtures/libsql-remote/package.json b/packages/db/test/fixtures/libsql-remote/package.json new file mode 100644 index 000000000..2970a62d5 --- /dev/null +++ b/packages/db/test/fixtures/libsql-remote/package.json @@ -0,0 +1,14 @@ +{ + "name": "@test/db-libsql-remote", + "version": "0.0.0", + "private": true, + "scripts": { + "dev": "astro dev", + "build": "astro build", + "preview": "astro preview" + }, + "dependencies": { + "@astrojs/db": "workspace:*", + "astro": "workspace:*" + } +} diff --git a/packages/db/test/fixtures/libsql-remote/src/pages/index.astro b/packages/db/test/fixtures/libsql-remote/src/pages/index.astro new file mode 100644 index 000000000..f36d44bd4 --- /dev/null +++ b/packages/db/test/fixtures/libsql-remote/src/pages/index.astro @@ -0,0 +1,11 @@ +--- +/// <reference path="../../.astro/db-types.d.ts" /> +import { User, db } from 'astro:db'; + +const users = await db.select().from(User); +--- + +<h2>Users</h2> +<ul class="users-list"> + {users.map((user) => <li>{user.name}</li>)} +</ul> |