Created
November 7, 2022 14:43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by Xata Codegen 0.18.0. Please do not edit. | |
import { buildClient } from '@xata.io/client'; | |
/** @typedef { import('./types').SchemaTables } SchemaTables */ | |
/** @type { SchemaTables } */ | |
const tables = [ | |
{ | |
name: 'Users', | |
columns: [ | |
{ name: 'username', type: 'string', unique: true }, | |
{ name: 'email', type: 'email', unique: true }, | |
{ name: 'fullName', type: 'text' }, | |
{ name: 'password', type: 'string' }, | |
{ name: 'provider', type: 'string' }, | |
{ name: 'profilePicture', type: 'string' }, | |
{ name: 'profilePictureId', type: 'string' }, | |
], | |
}, | |
{ | |
name: 'Cards', | |
columns: [ | |
{ name: 'name', type: 'string' }, | |
{ name: 'image', type: 'string' }, | |
{ name: 'video', type: 'string' }, | |
{ name: 'user', type: 'link', link: { table: 'Users' } }, | |
{ name: 'likes', type: 'multiple' }, | |
{ name: 'color', type: 'string' }, | |
{ name: 'front', type: 'text' }, | |
{ name: 'back', type: 'text' }, | |
{ name: 'video_id', type: 'string' }, | |
{ name: 'video_signature', type: 'string' }, | |
{ name: 'image_id', type: 'string' }, | |
{ name: 'image_signature', type: 'string' }, | |
{ name: 'category', type: 'string' }, | |
{ name: 'collectors', type: 'multiple' }, | |
], | |
}, | |
]; | |
/** @type { import('@xata.io/client').ClientConstructor<{}> } */ | |
const DatabaseClient = buildClient(); | |
const defaultOptions = { | |
databaseURL: | |
'https://Theodore-Kelechukwu-Onyejiaku-s-workspace-4666kh.eu-west-1.xata.sh/db/test', | |
}; | |
/** @typedef { import('./types').DatabaseSchema } DatabaseSchema */ | |
/** @extends DatabaseClient<DatabaseSchema> */ | |
export class XataClient extends DatabaseClient { | |
constructor(options) { | |
super({ ...defaultOptions, ...options }, tables); | |
} | |
} | |
let instance; | |
/** @type { () => XataClient } */ | |
export const getXataClient = () => { | |
if (instance) return instance; | |
instance = new XataClient(); | |
return instance; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment