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

drizzle-orm

Package Overview
Dependencies
Maintainers
4
Versions
977
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drizzle-orm - npm Package Compare versions

Comparing version 0.36.4-3c69a1f to 0.36.4-661b6f2

34

relations.d.ts

@@ -114,11 +114,5 @@ import { type AnyTable, type InferModelFromColumns, Table } from "./table.js";

export type OrderByOperators = ReturnType<typeof getOrderByOperators>;
export type FindTableByDBNameRelationalConfig<TSchema extends TablesRelationalConfig, TTableName extends string> = ExtractObjectValues<{
[K in keyof TSchema as TSchema[K]['table']['_']['name'] extends TTableName ? K : never]: TSchema[K];
export type FindTableInRelationalConfig<TSchema extends TablesRelationalConfig, TTargetTable extends Table, TTableName extends string = TTargetTable['_']['name']> = ExtractObjectValues<{
[K in keyof TSchema as TSchema[K]['tsName'] extends TTableName ? K : never]: TSchema[K];
}>;
export type FindTableByDBNameTablesRecord<TSchema extends Record<string, Table>, TTableName extends string> = ExtractObjectValues<{
[K in keyof TSchema as TSchema[K]['_']['name'] extends TTableName ? K : never]: TSchema[K];
}>;
export type FindTableInRelationsConfig<TSchema extends TablesRelationalConfig, TTargetTable extends Table, TTableName extends string = TTargetTable['_']['name'], TSchemaName extends string | undefined = TTargetTable['_']['schema'] extends undefined ? undefined : TTargetTable['_']['schema']> = ExtractObjectValues<{
[K in keyof TSchema as TSchema[K]['dbName'] extends TTableName ? TSchema[K]['schema'] extends undefined ? TSchemaName extends undefined ? K : never : TSchemaName extends TSchema[K]['schema'] ? K : never : never]: TSchema[K];
}>;
export type SQLOperator = {

@@ -135,3 +129,3 @@ sql: Operators['sql'];

with?: {
[K in keyof TTableConfig['relations']]?: true | (TTableConfig['relations'][K] extends Relation ? DBQueryConfig<TTableConfig['relations'][K] extends One<string, string> ? 'one' : 'many', TSchema, FindTableInRelationsConfig<TSchema, TTableConfig['relations'][K]['targetTable']>> : never);
[K in keyof TTableConfig['relations']]?: true | (TTableConfig['relations'][K] extends Relation ? DBQueryConfig<TTableConfig['relations'][K] extends One<string, string> ? 'one' : 'many', TSchema, FindTableInRelationalConfig<TSchema, TTableConfig['relations'][K]['targetTable']>> : never);
};

@@ -156,3 +150,3 @@ extras?: Record<string, SQLWrapper> | ((fields: Simplify<[

primaryKey: AnyColumn[];
schema?: string;
schema: string | undefined;
}

@@ -181,3 +175,3 @@ export type TablesRelationalConfig = Record<string, TableRelationalConfig>;

export type BuildRelationResult<TConfig extends TablesRelationalConfig, TInclude, TRelations extends Record<string, RelationsBuilderEntry>> = {
[K in NonUndefinedKeysOnly<TInclude> & keyof TRelations]: TRelations[K] extends infer TRel extends Relation ? BuildQueryResult<TConfig, FindTableInRelationsConfig<TConfig, TRel['targetTable']>, Assume<TInclude[K], true | Record<string, unknown>>> extends infer TResult ? TRel extends One<string, string> ? TResult | (Equal<TRel['optional'], true> extends true ? null : never) : TResult[] : never : TRelations[K] extends AggregatedField<infer TData> ? TData : never;
[K in NonUndefinedKeysOnly<TInclude> & keyof TRelations]: TRelations[K] extends infer TRel extends Relation ? BuildQueryResult<TConfig, FindTableInRelationalConfig<TConfig, TRel['targetTable']>, Assume<TInclude[K], true | Record<string, unknown>>> extends infer TResult ? TRel extends One<string, string> ? TResult | (Equal<TRel['optional'], true> extends true ? null : never) : TResult[] : never : TRelations[K] extends AggregatedField<infer TData> ? TData : never;
};

@@ -192,3 +186,3 @@ export type NonUndefinedKeysOnly<T> = ExtractObjectValues<{

}> : InferModelFromColumns<TTableConfig['columns']>) & (TFullSelection['extras'] extends Record<string, unknown> | ((...args: any[]) => Record<string, unknown>) ? {
[K in NonUndefinedKeysOnly<ReturnTypeOrValue<TFullSelection['extras']>>]: Assume<ReturnTypeOrValue<TFullSelection['extras']>[K], SQL>['_']['type'];
[K in NonUndefinedKeysOnly<ReturnTypeOrValue<TFullSelection['extras']>>]: ReturnType<Assume<ReturnTypeOrValue<TFullSelection['extras']>[K], SQLWrapper>['getSQL']>['_']['type'];
} : {}) & (TFullSelection['with'] extends Record<string, unknown> ? BuildRelationResult<TSchema, TFullSelection['with'], TTableConfig['relations']> : {})> : never;

@@ -275,3 +269,5 @@ export interface NormalizedRelation {

$not?: RelationsFilter<TColumns>[];
$raw?: (operators: Operators) => SQL;
$raw?: (columns: {
[K in keyof TColumns]: TColumns[K];
}, operators: Operators) => SQL;
};

@@ -283,3 +279,3 @@ export interface OneConfig<TSchema extends Record<string, Table>, TSourceColumns extends Readonly<[RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]]> | Readonly<RelationsBuilderColumnBase>, TTargetTableName extends string, TOptional extends boolean> {

} : RelationsBuilderColumnBase<TTargetTableName>;
where?: TSourceColumns extends [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]] ? RelationsFilter<FindTableByDBNameTablesRecord<TSchema, TSourceColumns[number]['_']['tableName']>['_']['columns']> : RelationsFilter<FindTableByDBNameTablesRecord<TSchema, Assume<TSourceColumns, RelationsBuilderColumnBase>['_']['tableName']>['_']['columns']>;
where?: TSourceColumns extends [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]] ? RelationsFilter<TSchema[TSourceColumns[number]['_']['tableName']]['_']['columns']> : RelationsFilter<TSchema[Assume<TSourceColumns, RelationsBuilderColumnBase>['_']['tableName']]['_']['columns']>;
optional?: TOptional;

@@ -294,3 +290,3 @@ alias?: string;

} : RelationsBuilderColumnBase<TTargetTableName>;
where?: TSourceColumns extends [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]] ? RelationsFilter<FindTableByDBNameTablesRecord<TSchema, TSourceColumns[number]['_']['tableName']>['_']['columns']> : RelationsFilter<FindTableByDBNameTablesRecord<TSchema, Assume<TSourceColumns, RelationsBuilderColumnBase>['_']['tableName']>['_']['columns']>;
where?: TSourceColumns extends [RelationsBuilderColumnBase, ...RelationsBuilderColumnBase[]] ? RelationsFilter<TSchema[TSourceColumns[number]['_']['tableName']]['_']['columns']> : RelationsFilter<TSchema[Assume<TSourceColumns, RelationsBuilderColumnBase>['_']['tableName']]['_']['columns']>;
alias?: string;

@@ -313,6 +309,6 @@ }

one: {
[K in keyof TTables]: OneFn<TTables, TTables[K]['_']['name']>;
[K in keyof TTables]: OneFn<TTables, K & string>;
};
many: {
[K in keyof TTables]: ManyFn<TTables, TTables[K]['_']['name']>;
[K in keyof TTables]: ManyFn<TTables, K & string>;
};

@@ -325,3 +321,3 @@ aggs: {

[TTableName in keyof TSchema & string]: {
[TColumnName in keyof TSchema[TTableName]['_']['columns']]: RelationsBuilderColumn<TSchema[TTableName]['_']['name'], TSchema[TTableName]['_']['columns'][TColumnName]['_']['data']>;
[TColumnName in keyof TSchema[TTableName]['_']['columns']]: RelationsBuilderColumn<TTableName, TSchema[TTableName]['_']['columns'][TColumnName]['_']['data']>;
} & RelationsBuilderTable<TTableName>;

@@ -332,3 +328,3 @@ } & RelationsHelperStatic<TSchema>;

};
export type RelationsBuilderEntry<TTables extends Record<string, Table> = Record<string, Table>, TSourceTableName extends string = string> = Relation<TTables[TSourceTableName]['_']['name'], TTables[keyof TTables & string]['_']['name']> | AggregatedField<any>;
export type RelationsBuilderEntry<TTables extends Record<string, Table> = Record<string, Table>, TSourceTableName extends string = string> = Relation<TSourceTableName, keyof TTables & string> | AggregatedField<any>;
export type ExtractTablesFromSchema<TSchema extends Record<string, unknown>> = {

@@ -335,0 +331,0 @@ [K in keyof TSchema as TSchema[K] extends Table ? K : never]: TSchema[K] extends Table ? TSchema[K] : never;

@@ -435,4 +435,7 @@ import { getTableUniqueName, Table } from "./table.js";

case "$raw": {
if (value)
parts.push(value(operators));
if (value) {
parts.push(
value(table[Columns], operators)
);
}
continue;

@@ -439,0 +442,0 @@ }

@@ -182,4 +182,4 @@ import type { CasingCache } from "../casing.js";

export declare namespace SQL {
class Aliased<T = unknown> implements SQLWrapper {
readonly sql: SQL;
class Aliased<T = unknown> implements SQLWrapper<T> {
readonly sql: SQL<T>;
readonly fieldAlias: string;

@@ -191,4 +191,4 @@ static readonly [entityKind]: string;

};
constructor(sql: SQL, fieldAlias: string);
getSQL(): SQL;
constructor(sql: SQL<T>, fieldAlias: string);
getSQL(): SQL<T>;
}

@@ -195,0 +195,0 @@ }

@@ -53,2 +53,3 @@ import { entityKind } from "../entity.js";

this.query[tableName] = new RelationalQueryBuilder(
resultKind,
relations.tables,

@@ -55,0 +56,0 @@ relations.tablesConfig,

@@ -12,2 +12,3 @@ import { entityKind } from "../../entity.js";

export declare class RelationalQueryBuilder<TMode extends 'sync' | 'async', TSchema extends TablesRelationalConfig, TFields extends TableRelationalConfig> {
private mode;
private tables;

@@ -21,5 +22,5 @@ private schema;

static readonly [entityKind]: string;
constructor(tables: Record<string, SQLiteTable>, schema: TSchema, tableNamesMap: Record<string, string>, table: SQLiteTable, tableConfig: TableRelationalConfig, dialect: SQLiteDialect, session: SQLiteSession<TMode, any, any, any, any, any>);
findMany<TConfig extends DBQueryConfig<'many', TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', TSchema, TFields>>): SQLiteRelationalQuery<TMode, BuildQueryResult<TSchema, TFields, TConfig>[]>;
findFirst<TConfig extends DBQueryConfig<'one', TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'one', TSchema, TFields>>): SQLiteRelationalQuery<TMode, BuildQueryResult<TSchema, TFields, TConfig> | undefined>;
constructor(mode: TMode, tables: Record<string, SQLiteTable>, schema: TSchema, tableNamesMap: Record<string, string>, table: SQLiteTable, tableConfig: TableRelationalConfig, dialect: SQLiteDialect, session: SQLiteSession<any, any, any, any, any, any>);
findMany<TConfig extends DBQueryConfig<'many', TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'many', TSchema, TFields>>): SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TConfig>[]>;
findFirst<TConfig extends DBQueryConfig<'one', TSchema, TFields>>(config?: KnownKeysOnly<TConfig, DBQueryConfig<'one', TSchema, TFields>>): SQLiteRelationalQueryKind<TMode, BuildQueryResult<TSchema, TFields, TConfig> | undefined>;
}

@@ -26,0 +27,0 @@ export declare class SQLiteRelationalQuery<TType extends 'sync' | 'async', TResult> extends QueryPromise<TResult> implements RunnableQuery<TResult, 'sqlite'>, SQLWrapper {

@@ -7,3 +7,4 @@ import { entityKind } from "../../entity.js";

class RelationalQueryBuilder {
constructor(tables, schema, tableNamesMap, table, tableConfig, dialect, session) {
constructor(mode, tables, schema, tableNamesMap, table, tableConfig, dialect, session) {
this.mode = mode;
this.tables = tables;

@@ -19,3 +20,3 @@ this.schema = schema;

findMany(config) {
return new SQLiteRelationalQuery(
return this.mode === "sync" ? new SQLiteSyncRelationalQuery(
this.tables,

@@ -30,6 +31,16 @@ this.schema,

"many"
) : new SQLiteRelationalQuery(
this.tables,
this.schema,
this.tableNamesMap,
this.table,
this.tableConfig,
this.dialect,
this.session,
config ?? true,
"many"
);
}
findFirst(config) {
return new SQLiteRelationalQuery(
return this.mode === "sync" ? new SQLiteSyncRelationalQuery(
this.tables,

@@ -44,2 +55,12 @@ this.schema,

"first"
) : new SQLiteRelationalQuery(
this.tables,
this.schema,
this.tableNamesMap,
this.table,
this.tableConfig,
this.dialect,
this.session,
config ?? true,
"first"
);

@@ -46,0 +67,0 @@ }

@@ -1,2 +0,2 @@

var version = "0.36.4-3c69a1f";
var version = "0.36.4-661b6f2";

@@ -3,0 +3,0 @@ declare const compatibilityVersion = 10;

// package.json
var version = "0.36.4-3c69a1f";
var version = "0.36.4-661b6f2";

@@ -4,0 +4,0 @@ // src/version.ts

Sorry, the diff of this file is too big to display

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

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

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

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

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

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