drizzle-orm-sqlite
Advanced tools
Comparing version 0.14.5 to 0.15.0-1766537
@@ -7,4 +7,5 @@ export * from './alias'; | ||
export * from './foreign-keys'; | ||
export * from './primary-keys'; | ||
export * from './indexes'; | ||
export * from './operations'; | ||
export * from './table'; |
@@ -23,2 +23,3 @@ "use strict"; | ||
__exportStar(require("./foreign-keys"), exports); | ||
__exportStar(require("./primary-keys"), exports); | ||
__exportStar(require("./indexes"), exports); | ||
@@ -25,0 +26,0 @@ __exportStar(require("./operations"), exports); |
{ | ||
"name": "drizzle-orm-sqlite", | ||
"version": "0.14.5", | ||
"version": "0.15.0-1766537", | ||
"description": "Drizzle ORM package for SQLite database", | ||
@@ -30,3 +30,3 @@ "main": "index.js", | ||
"better-sqlite3": ">=7 <9", | ||
"drizzle-orm": ">=0.14 <0.15", | ||
"drizzle-orm": ">=0.15 <0.16", | ||
"sqlite3": ">=5 <6", | ||
@@ -33,0 +33,0 @@ "@cloudflare/workers-types": ">=3" |
@@ -148,3 +148,3 @@ # Drizzle ORM | SQLite | ||
Declaring indexes and foreign keys | ||
Declaring indexes, foreign keys and composite primary keys | ||
```typescript | ||
@@ -182,2 +182,11 @@ import { sqliteTable, foreignKey, text, integer, index, uniqueIndex } from "drizzle-orm-sqlite"; | ||
const pkExample = sqliteTable('pk_example', { | ||
id: integer('id'), | ||
name: text('name').notNull(), | ||
email: text('email').notNull(), | ||
}, (table) => ({ | ||
// composite primary key on multiple columns | ||
compositePk: primaryKey(table.id, table.name) | ||
})); | ||
// you can have .where() on indexes | ||
@@ -184,0 +193,0 @@ index("name_idx").on(table.name).where(sql``) |
@@ -10,3 +10,4 @@ import { GetColumnData } from 'drizzle-orm'; | ||
import { IndexBuilder } from './indexes'; | ||
export declare type SQLiteTableExtraConfig = Record<string, IndexBuilder | CheckBuilder | ForeignKeyBuilder>; | ||
import { PrimaryKeyBuilder } from './primary-keys'; | ||
export declare type SQLiteTableExtraConfig = Record<string, IndexBuilder | CheckBuilder | ForeignKeyBuilder | PrimaryKeyBuilder>; | ||
export interface TableConfig { | ||
@@ -13,0 +14,0 @@ name: string; |
15
table.js
"use strict"; | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sqliteTable = exports.SQLiteTable = exports.ConflictConstraints = exports.Checks = exports.ForeignKeys = exports.Indexes = void 0; | ||
exports.sqliteTable = exports.SQLiteTable = exports.ConflictConstraints = exports.Checks = exports.PrimaryKeys = exports.ForeignKeys = exports.Indexes = void 0; | ||
const table_1 = require("drizzle-orm/table"); | ||
@@ -9,2 +9,3 @@ const checks_1 = require("./checks"); | ||
const indexes_1 = require("./indexes"); | ||
const primary_keys_1 = require("./primary-keys"); | ||
/** @internal */ | ||
@@ -15,2 +16,4 @@ exports.Indexes = Symbol('Indexes'); | ||
/** @internal */ | ||
exports.PrimaryKeys = Symbol('PrimaryKeys'); | ||
/** @internal */ | ||
exports.Checks = Symbol('Checks'); | ||
@@ -28,2 +31,4 @@ /** @internal */ | ||
this[_c] = {}; | ||
/** @internal */ | ||
this[_d] = {}; | ||
} | ||
@@ -35,3 +40,3 @@ toString() { | ||
exports.SQLiteTable = SQLiteTable; | ||
table_1.Table.Symbol.Columns, _a = exports.Indexes, _b = exports.ForeignKeys, _c = exports.Checks; | ||
table_1.Table.Symbol.Columns, _a = exports.Indexes, _b = exports.ForeignKeys, _c = exports.PrimaryKeys, _d = exports.Checks; | ||
/** @internal */ | ||
@@ -42,2 +47,3 @@ SQLiteTable.Symbol = Object.assign(table_1.Table.Symbol, { | ||
Checks: exports.Checks, | ||
PrimaryKeys: exports.PrimaryKeys, | ||
ConflictConstraints: exports.ConflictConstraints, | ||
@@ -69,2 +75,5 @@ }); | ||
} | ||
else if (builder instanceof primary_keys_1.PrimaryKeyBuilder) { | ||
table[exports.PrimaryKeys][name] = builder.build(table); | ||
} | ||
}); | ||
@@ -71,0 +80,0 @@ } |
@@ -6,2 +6,3 @@ import { SelectFieldsOrdered, SQLiteSelectFields } from './operations'; | ||
export declare function getTableForeignKeys<TTable extends AnySQLiteTable>(table: TTable): import("./foreign-keys").ForeignKey[]; | ||
export declare function getTableCompositePrimaryKeys<TTable extends AnySQLiteTable>(table: TTable): import("./primary-keys").PrimaryKey[]; | ||
export declare function getTableChecks<TTable extends AnySQLiteTable>(table: TTable): import("./checks").Check[]; | ||
@@ -8,0 +9,0 @@ export declare type OnConflict = 'rollback' | 'abort' | 'fail' | 'ignore' | 'replace'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.orderSelectedFields = exports.mapUpdateSet = exports.getTableChecks = exports.getTableForeignKeys = exports.getTableIndexes = exports.getTableColumns = void 0; | ||
exports.orderSelectedFields = exports.mapUpdateSet = exports.getTableChecks = exports.getTableCompositePrimaryKeys = exports.getTableForeignKeys = exports.getTableIndexes = exports.getTableColumns = void 0; | ||
const drizzle_orm_1 = require("drizzle-orm"); | ||
@@ -26,2 +26,8 @@ const sql_1 = require("drizzle-orm/sql"); | ||
exports.getTableForeignKeys = getTableForeignKeys; | ||
function getTableCompositePrimaryKeys(table) { | ||
const primaryKeys = table[table_1.SQLiteTable.Symbol.PrimaryKeys]; | ||
const keys = Reflect.ownKeys(primaryKeys); | ||
return keys.map((key) => primaryKeys[key]); | ||
} | ||
exports.getTableCompositePrimaryKeys = getTableCompositePrimaryKeys; | ||
function getTableChecks(table) { | ||
@@ -28,0 +34,0 @@ const checks = table[table_1.SQLiteTable.Symbol.Checks]; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192400
120
2616
544