Initial commit
This commit is contained in:
52
node_modules/drizzle-orm/sqlite-core/table.js
generated
vendored
Normal file
52
node_modules/drizzle-orm/sqlite-core/table.js
generated
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
import { entityKind } from "../entity.js";
|
||||
import { Table } from "../table.js";
|
||||
import { getSQLiteColumnBuilders } from "./columns/all.js";
|
||||
const InlineForeignKeys = Symbol.for("drizzle:SQLiteInlineForeignKeys");
|
||||
class SQLiteTable extends Table {
|
||||
static [entityKind] = "SQLiteTable";
|
||||
/** @internal */
|
||||
static Symbol = Object.assign({}, Table.Symbol, {
|
||||
InlineForeignKeys
|
||||
});
|
||||
/** @internal */
|
||||
[Table.Symbol.Columns];
|
||||
/** @internal */
|
||||
[InlineForeignKeys] = [];
|
||||
/** @internal */
|
||||
[Table.Symbol.ExtraConfigBuilder] = void 0;
|
||||
}
|
||||
function sqliteTableBase(name, columns, extraConfig, schema, baseName = name) {
|
||||
const rawTable = new SQLiteTable(name, schema, baseName);
|
||||
const parsedColumns = typeof columns === "function" ? columns(getSQLiteColumnBuilders()) : columns;
|
||||
const builtColumns = Object.fromEntries(
|
||||
Object.entries(parsedColumns).map(([name2, colBuilderBase]) => {
|
||||
const colBuilder = colBuilderBase;
|
||||
colBuilder.setName(name2);
|
||||
const column = colBuilder.build(rawTable);
|
||||
rawTable[InlineForeignKeys].push(...colBuilder.buildForeignKeys(column, rawTable));
|
||||
return [name2, column];
|
||||
})
|
||||
);
|
||||
const table = Object.assign(rawTable, builtColumns);
|
||||
table[Table.Symbol.Columns] = builtColumns;
|
||||
table[Table.Symbol.ExtraConfigColumns] = builtColumns;
|
||||
if (extraConfig) {
|
||||
table[SQLiteTable.Symbol.ExtraConfigBuilder] = extraConfig;
|
||||
}
|
||||
return table;
|
||||
}
|
||||
const sqliteTable = (name, columns, extraConfig) => {
|
||||
return sqliteTableBase(name, columns, extraConfig);
|
||||
};
|
||||
function sqliteTableCreator(customizeTableName) {
|
||||
return (name, columns, extraConfig) => {
|
||||
return sqliteTableBase(customizeTableName(name), columns, extraConfig, void 0, name);
|
||||
};
|
||||
}
|
||||
export {
|
||||
InlineForeignKeys,
|
||||
SQLiteTable,
|
||||
sqliteTable,
|
||||
sqliteTableCreator
|
||||
};
|
||||
//# sourceMappingURL=table.js.map
|
||||
Reference in New Issue
Block a user