UNPKG

@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

176 lines (172 loc) 5.43 kB
"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/sqlite.ts var sqlite_exports = {}; __export(sqlite_exports, { blob: () => blob, integer: () => integer, real: () => real, text: () => text }); module.exports = __toCommonJS(sqlite_exports); var import_databases = require("@palmares/databases"); // 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)); } }; // src/fields/custom-fields/sqlite.ts function real() { const RealField = import_databases.Field._overrideType({ typeName: "real" }); const instance = RealField.new({}).allowNull(false); return instance._setNewBuilderMethods(); } __name(real, "real"); function integer(args) { const IntegerField = import_databases.Field._overrideType({ typeName: "integer" }); const instance = IntegerField.new({}).allowNull(false); instance["__customAttributes"] = { args }; return instance._setNewBuilderMethods(); } __name(integer, "integer"); function text(args) { const CustomTextField = import_databases.TextField._overrideType({ typeName: "text" }); const instance = CustomTextField.new({}).allowNull(false).allowBlank(true); instance["__customAttributes"] = { args }; return instance._setNewBuilderMethods(new DefaultBuilder(instance, "text")); } __name(text, "text"); function blob(args) { const CustomTextField = import_databases.Field._overrideType({ typeName: "text" }); const instance = CustomTextField.new({}).allowNull(false); instance["__customAttributes"] = { args }; return instance._setNewBuilderMethods(); } __name(blob, "blob"); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { blob, integer, real, text });