Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

drizzle-orm-pg

Package Overview
Dependencies
Maintainers
3
Versions
170
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drizzle-orm-pg - npm Package Compare versions

Comparing version 0.12.0-beta.2 to 0.12.0-beta.3

17

foreign-keys.d.ts

@@ -12,2 +12,5 @@ import { TableName } from 'drizzle-orm/branded-types';

protected brand: 'PgForeignKeyBuilder';
protected typeKeeper: {
foreignTableName: TForeignTableName;
};
constructor(config: () => {

@@ -34,10 +37,12 @@ columns: AnyPgColumn<TTableName>[];

export declare type AnyForeignKey = ForeignKey<any, any>;
declare type ColumnsWithTable<TTableName extends TableName, TColumns extends AnyPgColumn | [AnyPgColumn, ...AnyPgColumn[]]> = TColumns extends AnyPgColumn<any, infer TType> ? AnyPgColumn<TTableName, TType> : TColumns extends AnyPgColumn[] ? {
declare type ColumnsWithTable<TTableName extends TableName, TColumns extends AnyPgColumn[]> = {
[Key in keyof TColumns]: TColumns[Key] extends AnyPgColumn<any, infer TType> ? AnyPgColumn<TTableName, TType> : never;
} : never;
};
export declare type GetColumnsTable<TColumns extends AnyPgColumn | AnyPgColumn[]> = (TColumns extends AnyPgColumn ? TColumns : TColumns extends AnyPgColumn[] ? TColumns[number] : never) extends AnyPgColumn<infer TTableName> ? TTableName : never;
export declare function foreignKey<TColumns extends AnyPgColumn | [AnyPgColumn, ...AnyPgColumn[]], TForeignColumns extends ColumnsWithTable<TableName, TColumns>>(config: () => [
columns: TColumns,
foreignColumns: TForeignColumns
]): ForeignKeyBuilder<GetColumnsTable<TColumns>, GetColumnsTable<TForeignColumns>>;
export declare type NotUnion<T, T1 = T> = T extends T ? [T1] extends [T] ? T1 : never : never;
export declare type NotFKBuilderWithUnion<T> = T extends ForeignKeyBuilder<any, infer TForeignTableName> ? [NotUnion<TForeignTableName>] extends [never] ? 'Only columns from the same table are allowed in foreignColumns' : T : never;
export declare function foreignKey<TColumns extends [AnyPgColumn, ...AnyPgColumn[]], TForeignTableName extends TableName, TForeignColumns extends ColumnsWithTable<TForeignTableName, TColumns>>(config: () => {
columns: TColumns;
foreignColumns: TForeignColumns;
}): NotFKBuilderWithUnion<ForeignKeyBuilder<GetColumnsTable<TColumns>, GetColumnsTable<TForeignColumns>>>;
export {};

@@ -52,3 +52,3 @@ "use strict";

function mappedConfig() {
const [columns, foreignColumns] = config();
const { columns, foreignColumns } = config();
return {

@@ -55,0 +55,0 @@ columns: Array.isArray(columns) ? columns : [columns],

{
"name": "drizzle-orm-pg",
"version": "0.12.0-beta.2",
"version": "0.12.0-beta.3",
"description": "Drizzle ORM package for PostgreSQL database",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -45,7 +45,14 @@ "use strict";

legalAge: (0, constraints_1.constraint)('legalAge', (0, drizzle_orm_1.sql) `${users.age1} > 18`),
usersClassFK: (0, foreign_keys_1.foreignKey)(() => [users.subClass, classes.subClass]),
usersClassComplexFK: (0, foreign_keys_1.foreignKey)(() => [
[users.class, users.subClass],
[classes.class, classes.subClass],
]),
usersClassFK: (0, foreign_keys_1.foreignKey)(() => ({
columns: [users.subClass],
foreignColumns: [classes.subClass],
})),
usersClassComplexFK: (0, foreign_keys_1.foreignKey)(() => ({
columns: [users.class, users.subClass],
foreignColumns: [classes.class, classes.subClass],
})),
fk: (0, foreign_keys_1.foreignKey)(() => ({
columns: [users.homeCity, users.currentCity],
foreignColumns: [cities.id, cities.id],
})),
}));

@@ -62,2 +69,5 @@ const cities = (0, table_1.pgTable)('cities_table', {

});
const countries = (0, table_1.pgTable)('countries_table', {
id: (0, columns_1.integer)('id'),
});
console.log((0, utils_1.getTableColumns)(users));

@@ -64,0 +74,0 @@ function main() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc