-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathxata.ts
77 lines (66 loc) · 2.02 KB
/
xata.ts
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Generated by Xata Codegen 0.30.0. Please do not edit.
import { buildClient } from "@xata.io/client";
import type {
BaseClientOptions,
SchemaInference,
XataRecord,
} from "@xata.io/client";
const tables = [
{
name: "webstore-orders",
columns: [
{ name: "sku", type: "string" },
{ name: "full_name", type: "string" },
{ name: "email", type: "email" },
{ name: "status", type: "text" },
],
},
{
name: "inventory-products",
columns: [
{ name: "sku", type: "string", unique: true },
{ name: "name", type: "string" },
{ name: "price", type: "float" },
{ name: "meta", type: "json" },
{
name: "inventory_count",
type: "int",
notNull: true,
defaultValue: "0",
},
{ name: "reserve_count", type: "int", notNull: true, defaultValue: "0" },
{ name: "type", type: "string" },
{
name: "image_main",
type: "file[]",
"file[]": { defaultPublicAccess: true },
},
],
},
] as const;
export type SchemaTables = typeof tables;
export type InferredTypes = SchemaInference<SchemaTables>;
export type WebstoreOrders = InferredTypes["webstore-orders"];
export type WebstoreOrdersRecord = WebstoreOrders & XataRecord;
export type InventoryProducts = InferredTypes["inventory-products"];
export type InventoryProductsRecord = InventoryProducts & XataRecord;
export type DatabaseSchema = {
"webstore-orders": WebstoreOrdersRecord;
"inventory-products": InventoryProductsRecord;
};
const DatabaseClient = buildClient();
const defaultOptions = {
databaseURL:
"https://Phil-Leggetter-s-workspace-hc84d7.us-east-1.xata.sh/db/serverless-eda-vercel",
};
export class XataClient extends DatabaseClient<DatabaseSchema> {
constructor(options?: BaseClientOptions) {
super({ ...defaultOptions, ...options }, tables);
}
}
let instance: XataClient | undefined = undefined;
export const getXataClient = () => {
if (instance) return instance;
instance = new XataClient();
return instance;
};