@palmares/drizzle-engine
Version:
This is the engine that wraps the hole drizzle interface in a way palmares can understand and have full control of
101 lines (99 loc) • 3.09 kB
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/fields/custom-fields/utils.ts
var DefaultBuilder = class _DefaultBuilder {
static {
__name(this, "DefaultBuilder");
}
_;
constructor(fieldInstance, type) {
this._ = {
field: fieldInstance,
type
};
}
$type() {
return this._.field._setPartialAttributes()(this._.field["__customAttributes"])._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
$default(cb) {
return this._.field._setPartialAttributes()({
type: this._.type,
args: this._.field["__customAttributes"]?.["args"],
options: {
...this._.field["__customAttributes"]?.["options"] || {},
$default: [
cb
]
}
})._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
$onUpdate(cb) {
return this._.field._setPartialAttributes()({
type: this._.type,
args: this._.field["__customAttributes"]?.["args"],
options: {
...this._.field["__customAttributes"]?.["options"] || {},
$onUpdate: [
cb
]
}
})._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
references(cb) {
return this._.field._setPartialAttributes()({
type: this._.type,
args: this._.field["__customAttributes"]?.["args"],
options: {
...this._.field["__customAttributes"]?.["options"] || {},
references: [
cb
]
}
})._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
primaryKey() {
return this._.field._setPartialAttributes()({
type: this._.type,
args: this._.field["__customAttributes"]?.["args"],
options: {
...this._.field["__customAttributes"]?.["options"] || {},
primaryKey: true
}
})._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
unique() {
return this._.field._setPartialAttributes()({
type: this._.type,
args: this._.field["__customAttributes"]?.["args"],
options: {
...this._.field["__customAttributes"]?.["options"] || {},
unique: true
}
})._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
notNull() {
return this._.field._setPartialAttributes()({
type: this._.type,
args: this._.field["__customAttributes"]?.["args"],
options: {
...this._.field["__customAttributes"]?.["options"] || {},
notNull: []
}
})._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
generatedAlwaysAs(cb) {
return this._.field._setPartialAttributes()({
type: this._.type,
args: this._.field["__customAttributes"]?.["args"],
options: {
...this._.field["__customAttributes"]?.["options"] || {},
generatedAlwaysAs: [
cb
]
}
})._setNewBuilderMethods(new _DefaultBuilder(this._.field, this._.type));
}
};
export {
DefaultBuilder
};