Xata types and client

This val was generated by the Xata CLI for a toy database that I set up. The output of the CLI was then copied into Val Town. See their documentation for usage and this val for an example.

Readme
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Generated by Xata Codegen 0.28.0. Please do not edit.
import { buildClient } from "npm:@xata.io/client@latest";
import type { BaseClientOptions, SchemaInference, XataRecord } from "npm:@xata.io/client@latest";
const tables = [
{
name: "Posts",
columns: [
{ name: "title", type: "string" },
{ name: "labels", type: "multiple" },
{ name: "slug", type: "string" },
{ name: "text", type: "text" },
{ name: "author", type: "link", link: { table: "Users" } },
{ name: "createdAt", type: "datetime" },
{ name: "views", type: "int" },
],
},
{
name: "Users",
columns: [
{ name: "name", type: "string" },
{ name: "email", type: "email" },
{ name: "bio", type: "text" },
],
revLinks: [{ column: "author", table: "Posts" }],
},
] as const;
export type SchemaTables = typeof tables;
export type InferredTypes = SchemaInference<SchemaTables>;
export type Posts = InferredTypes["Posts"];
export type PostsRecord = Posts & XataRecord;
export type Users = InferredTypes["Users"];
export type UsersRecord = Users & XataRecord;
export type DatabaseSchema = {
Posts: PostsRecord;
Users: UsersRecord;
};
const DatabaseClient = buildClient();
const defaultOptions = {
databaseURL: "https://Nico-Baier-s-workspace-1rbjms.us-east-1.xata.sh/db/valtown",
};
export class XataClient extends DatabaseClient<DatabaseSchema> {
constructor(options?: BaseClientOptions) {
👆 This is a val. Vals are TypeScript snippets of code, written in the browser and run on our servers. Create scheduled functions, email yourself, and persist small pieces of data — all from the browser.