CoolFace
Apppublic

AK-21/Graphite-Industrial-Intelligence

sourceHugging Faceupdated 3mo agoView on Hugging Face
0likes
table.js52 linesDownload Raw Back to sqlite-core
1import { entityKind } from "../entity.js";2import { Table } from "../table.js";3import { getSQLiteColumnBuilders } from "./columns/all.js";4const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");5class SQLiteTable extends Table {6  static [entityKind] = "SQLiteTable";7  /** @internal */8  static Symbol = Object.assign({}, Table.Symbol, {9    InlineForeignKeys10  });11  /** @internal */12  [Table.Symbol.Columns];13  /** @internal */14  [InlineForeignKeys] = [];15  /** @internal */16  [Table.Symbol.ExtraConfigBuilder] = void 0;17}18function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {19  const rawTable = new SQLiteTable(name, schema, baseName);20  const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;21  const builtColumns = Object.fromEntries(22    Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {23      const colBuilder = colBuilderBase;24      colBuilder.setName(name2);25      const column = colBuilder.build(rawTable);26      rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));27      return [name2, column];28    })29  );30  const table = Object.assign(rawTable, builtColumns);31  table[Table.Symbol.Columns] = builtColumns;32  table[Table.Symbol.ExtraConfigColumns] = builtColumns;33  if (extraConfig) {34    table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;35  }36  return table;37}38const sqliteTable = (name, columns, extraConfig) => {39  return sqliteTableBase(name, columns, extraConfig);40};41function sqliteTableCreator(customizeTableName) {42  return (name, columns, extraConfig) => {43    return sqliteTableBase(customizeTableName(name), columns, extraConfig, void 0, name);44  };45}46export {47  InlineForeignKeys,48  SQLiteTable,49  sqliteTable,50  sqliteTableCreator51};52//# sourceMappingURL=table.js.map