prisma-util
Version:
Prisma Util is an easy to use tool that merges multiple Prisma schema files, allows extending of models, resolves naming conflicts both manually and automatically and provides easy access to Prisma commands and timing reports. It's mostly a plug-and-play
43 lines (42 loc) • 1.58 kB
TypeScript
import AbstractCreator from './creator.js';
import Enum from './enum.js';
import { SchemaCreator } from './index.js';
/** Hidden column class for internal use. */
declare class Column {
/** Column name. */
readonly name: string;
/** Column type. */
readonly type: string;
/** Column constraints. */
readonly constraints: string[];
constructor(name: string, type: string, ...constraints: string[]);
}
/** Model that will be created in your Prisma schema.
*
* When resolving conflicts, this model will be displayed as `codeSchemas:[ModelName]` so you can differentiate between .schema files and code generated models.
*
* For additional functionality, you can use the same format (`codeSchemas:[ModelName].[columnName]`) to remap columns using the Automatic Remapper.
*/
export default class Model extends AbstractCreator {
/** Reference to creator for handling chaining. */
private creator;
/** Model name. */
_name: string;
/** List of columns. */
columns: Column[];
/** List of model attributes. */
attributes: string[];
constructor(creator: SchemaCreator, name: string);
/** Change this model's name. */
name(name: string): this;
/** Create a new column. */
column(name: string, type: string, ...constraints: string[]): this;
/**Add constraints to this model. */
constraints(...constraints: string[]): this;
model(name: string): Model;
enum(name: string): Enum;
/** You should not call this method yourself. */
beforeBuild(): this;
build(): string;
}
export {};