UNPKG

tspace-mysql

Version:

Tspace MySQL is a promise-based ORM for Node.js, designed with modern TypeScript and providing type safety for schema databases.

78 lines 2.89 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.postSchemaArray = exports.postSchemaObject = exports.userSchemaArray = exports.userSchemaObject = exports.PostUser = exports.Post = exports.User = void 0; const lib_1 = require("../lib"); class User extends lib_1.Model { constructor() { super(); this.useUUID(); this.useTimestamp(); this.useSoftDelete(); this.hasMany({ model: Post, name: 'posts' }); this.hasOne({ model: Post, name: 'post' }); } } exports.User = User; class Post extends lib_1.Model { constructor() { super(); this.useUUID(); this.useTimestamp(); this.useSoftDelete(); this.belongsTo({ name: 'user', model: User }); this.belongsToMany({ name: 'subscribers', model: User, modelPivot: PostUser }); } } exports.Post = Post; class PostUser extends lib_1.Model { constructor() { super(); this.useUUID(); this.useTimestamp(); this.useSoftDelete(); this.useTableSingular(); } } exports.PostUser = PostUser; exports.userSchemaObject = { type: 'object', properties: { id: { type: 'integer' }, uuid: { anyOf: [{ type: 'string' }, { type: 'null' }] }, email: { type: 'string' }, name: { anyOf: [{ type: 'string' }, { type: 'null' }] }, username: { anyOf: [{ type: 'string' }, { type: 'null' }] }, password: { type: 'string' }, status: { anyOf: [{ type: 'boolean' }, { type: 'integer' }, { type: 'null' }] }, created_at: { anyOf: [{ type: 'string' }, { type: "object", format: "date" }, { type: 'null' }] }, updated_at: { anyOf: [{ type: 'string' }, { type: "object", format: "date" }, { type: 'null' }] }, deleted_at: { anyOf: [{ type: 'string' }, { type: "object", format: "date" }, { type: 'null' }] }, } }; exports.userSchemaArray = { type: 'array', items: { ...exports.userSchemaObject } }; exports.postSchemaObject = { type: 'object', properties: { id: { type: 'integer' }, uuid: { anyOf: [{ type: 'string' }, { type: 'null' }] }, userId: { anyOf: [{ type: 'integer' }, { type: 'null' }] }, title: { type: 'string' }, subtitle: { anyOf: [{ type: 'string' }, { type: 'null' }] }, description: { anyOf: [{ type: 'string' }, { type: 'null' }] }, created_at: { anyOf: [{ type: 'string' }, { type: "object", format: "date" }, { type: 'null' }] }, updated_at: { anyOf: [{ type: 'string' }, { type: "object", format: "date" }, { type: 'null' }] }, deleted_at: { anyOf: [{ type: 'string' }, { type: "object", format: "date" }, { type: 'null' }] }, } }; exports.postSchemaArray = { type: 'array', items: { ...exports.postSchemaObject } }; //# sourceMappingURL=default-spec.js.map