Skip to content

Commit

Permalink
Add test schema file
Browse files Browse the repository at this point in the history
  • Loading branch information
3commascapital committed Sep 20, 2024
1 parent 52fff1b commit 3ab966e
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions packages/core/src/database/schemas.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { createSchema } from "@/schema/schema.js";
import { zeroAddress } from "viem";

export const petPerson = createSchema((p) => ({
PetKind: p.createEnum(["CAT", "DOG"]),
Pet: p.createTable(
{
id: p.string(),
name: p.string(),
age: p.int().optional(),
bigAge: p.bigint().optional(),
kind: p.enum("PetKind").optional(),
},
{
multiIndex: p.index(["name", "age"]),
},
),
Person: p.createTable(
{
id: p.string(),
name: p.string(),
},
{
nameIndex: p.index("name"),
},
),
}));

export const dogApple = createSchema((p) => ({
Dog: p.createTable({
id: p.string(),
name: p.string(),
age: p.int().optional(),
bigAge: p.bigint().optional(),
}),
Apple: p.createTable({
id: p.string(),
name: p.string(),
}),
}));

export const dogWithDefaults = createSchema((p) => ({
Dog: p.createTable({
id: p.string().default("0"),
name: p.string().default("firstname"),
age: p.int().default(5).optional(),
bigAge: p.bigint().default(5n).optional(),
bowl: p.hex().default(zeroAddress),
toys: p.json().default({
bone: "sofa",
ball: "bed",
}),
commands: p.json().default([
"sit",
"stay",
{
paw: {
right: true,
left: false,
},
},
]),
}),
}));

0 comments on commit 3ab966e

Please sign in to comment.