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.

99 lines (98 loc) 3.12 kB
import { TRelationQueryOptions, TValidateSchemaDecorator } from "../types"; import { Blueprint } from "./Blueprint"; /** * * @param {string} name * @returns {Function} * * @example * * @Table('users') * class User extends Model {} */ export declare const Table: (name: string) => Function; /** * * @returns {Function} * * @example * * @TableSingular() * class User extends Model {} */ export declare const TableSingular: () => Function; /** * * @returns {Function} * * @example * * @TablePlural() * class User extends Model {} */ export declare const TablePlural: () => Function; /** * * @param {Blueprint} blueprint * @returns {Function} * * @example * * class User extends Model { * * @Column(() => Blueprint.int().notNull().primary().autoIncrement()) * public id!: number * * @Column(() => Blueprint.varchar(50).null()) * public uuid!: string * } */ export declare const Column: (blueprint: () => Blueprint) => Function; /** * * @param {TValidateSchemaDecorator} validate * @returns {Function} * * @example * * class User extends Model { * * @Column(() => Blueprint.int().notNull().primary().autoIncrement()) * public id!: number * * * @Column(() => Blueprint.varchar(50).null()) * public uuid!: string * * @Column(() => Blueprint.varchar(50).null()) * @Validate({ * type : String, * require : true, * length : 50, * match: /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/, * unique : true, * fn : (email : string) => /^[a-zA-Z0-9._]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(email) * }) * public email!: string * } */ export declare const Validate: (validate: TValidateSchemaDecorator) => Function; export declare const UUID: (column?: string) => (constructor: Function) => void; export declare const Observer: (observer: new () => { selected: Function; created: Function; updated: Function; deleted: Function; }) => (constructor: Function) => void; export declare const Timestamp: (timestampColumns?: { createdAt: string; updatedAt: string; }) => (constructor: Function) => void; export declare const SoftDelete: (column?: string) => (constructor: Function) => void; export declare const Pattern: (pattern: 'camelCase' | 'snake_case') => (constructor: Function) => void; export declare const CamelCase: () => (constructor: Function) => void; export declare const SnakeCase: () => (constructor: Function) => void; export declare const HasOne: ({ name, as, model, localKey, foreignKey, freezeTable }: TRelationQueryOptions) => (target: any, key: string) => void; export declare const HasMany: ({ name, as, model, localKey, foreignKey, freezeTable }: TRelationQueryOptions) => (target: any, key: string) => void; export declare const BelongsTo: ({ name, as, model, localKey, foreignKey, freezeTable }: TRelationQueryOptions) => (target: any, key: string) => void; export declare const BelongsToMany: ({ name, as, model, localKey, foreignKey, freezeTable, pivot, oldVersion, modelPivot }: TRelationQueryOptions) => (target: any, key: string) => void;