CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
unique-constraint.cjs81 linesDownload Raw Back to sqlite-core
1"use strict";2var __defProp = Object.defineProperty;3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;4var __getOwnPropNames = Object.getOwnPropertyNames;5var __hasOwnProp = Object.prototype.hasOwnProperty;6var __export = (target, all) => {7  for (var name in all)8    __defProp(target, name, { get: all[name], enumerable: true });9};10var __copyProps = (to, from, except, desc) => {11  if (from && typeof from === "object" || typeof from === "function") {12    for (let key of __getOwnPropNames(from))13      if (!__hasOwnProp.call(to, key) && key !== except)14        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });15  }16  return to;17};18var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);19var unique_constraint_exports = {};20__export(unique_constraint_exports, {21  UniqueConstraint: () => UniqueConstraint,22  UniqueConstraintBuilder: () => UniqueConstraintBuilder,23  UniqueOnConstraintBuilder: () => UniqueOnConstraintBuilder,24  unique: () => unique,25  uniqueKeyName: () => uniqueKeyName26});27module.exports = __toCommonJS(unique_constraint_exports);28var import_entity = require("../entity.cjs");29var import_table_utils = require("../table.utils.cjs");30function uniqueKeyName(table, columns) {31  return `${table[import_table_utils.TableName]}_${columns.join("_")}_unique`;32}33function unique(name) {34  return new UniqueOnConstraintBuilder(name);35}36class UniqueConstraintBuilder {37  constructor(columns, name) {38    this.name = name;39    this.columns = columns;40  }41  static [import_entity.entityKind] = "SQLiteUniqueConstraintBuilder";42  /** @internal */43  columns;44  /** @internal */45  build(table) {46    return new UniqueConstraint(table, this.columns, this.name);47  }48}49class UniqueOnConstraintBuilder {50  static [import_entity.entityKind] = "SQLiteUniqueOnConstraintBuilder";51  /** @internal */52  name;53  constructor(name) {54    this.name = name;55  }56  on(...columns) {57    return new UniqueConstraintBuilder(columns, this.name);58  }59}60class UniqueConstraint {61  constructor(table, columns, name) {62    this.table = table;63    this.columns = columns;64    this.name = name ?? uniqueKeyName(this.table, this.columns.map((column) => column.name));65  }66  static [import_entity.entityKind] = "SQLiteUniqueConstraint";67  columns;68  name;69  getName() {70    return this.name;71  }72}73// Annotate the CommonJS export names for ESM import in node:740 && (module.exports = {75  UniqueConstraint,76  UniqueConstraintBuilder,77  UniqueOnConstraintBuilder,78  unique,79  uniqueKeyName80});81//# sourceMappingURL=unique-constraint.cjs.map