Skip to content

Instantly share code, notes, and snippets.

@Theodore-Kelechukwu-Onyejiaku
Created November 7, 2022 14:43
Show Gist options
  • Save Theodore-Kelechukwu-Onyejiaku/1e2e1ad1d04e2f307b1fcb37296706d8 to your computer and use it in GitHub Desktop.
Save Theodore-Kelechukwu-Onyejiaku/1e2e1ad1d04e2f307b1fcb37296706d8 to your computer and use it in GitHub Desktop.
// 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