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
39 lines (38 loc) • 1.15 kB
JavaScript
import AbstractCreator from "./creator.js";
/** Enum that will be created in your Prisma schema.
*
* When resolving conflicts, this enum will be displayed as `codeSchemas:[EnumName]` 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 Enum extends AbstractCreator {
constructor(creator, name) {
super();
this.creator = creator;
this._name = name;
this.items = [];
}
/** Change this enum's name. */
name(name) {
this._name = name;
return this;
}
/** Add an enum item. */
item(name) {
this.items.push(name);
return this;
}
model(name) {
return this.creator.pushEnum(this).model(name);
}
enum(name) {
return this.creator.pushEnum(this).enum(name);
}
/** You should not call this method yourself. */
beforeBuild() {
return this;
}
build() {
return this.creator.pushEnum(this).build();
}
}