mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
[ci] format
This commit is contained in:
parent
96c8bca19a
commit
4e1a9c5299
5 changed files with 20 additions and 28 deletions
|
@ -145,7 +145,7 @@ export const jsonColumnSchema = z.object({
|
|||
}),
|
||||
});
|
||||
|
||||
export const columnSchema = z.discriminatedUnion("type", [
|
||||
export const columnSchema = z.discriminatedUnion('type', [
|
||||
booleanColumnSchema,
|
||||
numberColumnSchema,
|
||||
textColumnSchema,
|
||||
|
|
|
@ -6,5 +6,5 @@ export default defineConfig({
|
|||
integrations: [db()],
|
||||
devToolbar: {
|
||||
enabled: false,
|
||||
}
|
||||
},
|
||||
});
|
||||
|
|
12
packages/db/test/fixtures/basics/db/config.ts
vendored
12
packages/db/test/fixtures/basics/db/config.ts
vendored
|
@ -10,17 +10,17 @@ const Author = defineTable({
|
|||
|
||||
const User = defineTable({
|
||||
columns: {
|
||||
id: column.text({ primaryKey: true, optional: false }),
|
||||
username: column.text({ optional: false, unique: true }),
|
||||
password: column.text({ optional: false }),
|
||||
id: column.text({ primaryKey: true, optional: false }),
|
||||
username: column.text({ optional: false, unique: true }),
|
||||
password: column.text({ optional: false }),
|
||||
},
|
||||
});
|
||||
|
||||
const Session = defineTable({
|
||||
columns: {
|
||||
id: column.text({ primaryKey: true, optional: false }),
|
||||
expiresAt: column.number({ optional: false, name: "expires_at" }),
|
||||
userId: column.text({ optional: false, references: () => User.columns.id, name: "user_id" }),
|
||||
id: column.text({ primaryKey: true, optional: false }),
|
||||
expiresAt: column.number({ optional: false, name: 'expires_at' }),
|
||||
userId: column.text({ optional: false, references: () => User.columns.id, name: 'user_id' }),
|
||||
},
|
||||
});
|
||||
|
||||
|
|
14
packages/db/test/fixtures/basics/db/seed.ts
vendored
14
packages/db/test/fixtures/basics/db/seed.ts
vendored
|
@ -1,6 +1,6 @@
|
|||
import { asDrizzleTable } from '@astrojs/db/utils';
|
||||
import { Themes as ThemesConfig } from './theme';
|
||||
import { Author, User, Session, db } from 'astro:db';
|
||||
import { Author, Session, User, db } from 'astro:db';
|
||||
|
||||
const Themes = asDrizzleTable('Themes', ThemesConfig);
|
||||
export default async function () {
|
||||
|
@ -18,15 +18,7 @@ export default async function () {
|
|||
{ name: 'Bjorn' },
|
||||
{ name: 'Sarah' },
|
||||
]),
|
||||
db
|
||||
.insert(User)
|
||||
.values([
|
||||
{ id: 'mario', username: 'Mario', password: 'itsame' }
|
||||
]),
|
||||
db
|
||||
.insert(Session)
|
||||
.values([
|
||||
{ id: '12345', expiresAt: new Date().valueOf(), userId: 'mario' }
|
||||
]),
|
||||
db.insert(User).values([{ id: 'mario', username: 'Mario', password: 'itsame' }]),
|
||||
db.insert(Session).values([{ id: '12345', expiresAt: new Date().valueOf(), userId: 'mario' }]),
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -2,17 +2,17 @@
|
|||
import { db, Session, User, eq } from 'astro:db';
|
||||
|
||||
const users = await db.select().from(User);
|
||||
const sessions = await db.select()
|
||||
.from(Session)
|
||||
.innerJoin(User, eq(Session.userId, User.id));
|
||||
const sessions = await db.select().from(Session).innerJoin(User, eq(Session.userId, User.id));
|
||||
---
|
||||
|
||||
<h2>Sessions</h2>
|
||||
<ul class="sessions-list">
|
||||
{sessions.map(({ Session, User }) => (
|
||||
<li>
|
||||
<div class="session-id">{Session.id}</div>
|
||||
<div class="username">{User.username}</div>
|
||||
</li>
|
||||
))}
|
||||
{
|
||||
sessions.map(({ Session, User }) => (
|
||||
<li>
|
||||
<div class="session-id">{Session.id}</div>
|
||||
<div class="username">{User.username}</div>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue