@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
124 lines (122 loc) • 4.07 kB
JavaScript
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/fields/custom-fields/utils.ts
var utils_exports = {};
__export(utils_exports, {
DefaultBuilder: () => DefaultBuilder
});
module.exports = __toCommonJS(utils_exports);
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));
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DefaultBuilder
});