drizzle-orm-sqlite
Advanced tools
Comparing version 0.12.0-beta.13 to 0.12.0-beta.14
@@ -27,3 +27,3 @@ import { MigrationMeta } from 'drizzle-orm'; | ||
private buildSelection; | ||
buildSelectQuery({ fields, where, table, joins, orderBy, limit, offset }: SQLiteSelectConfig): SQL; | ||
buildSelectQuery({ fields, where, table, joins, orderBy, groupBy, limit, offset }: SQLiteSelectConfig): SQL; | ||
buildInsertQuery({ table, values, onConflict, returning }: SQLiteInsertConfig): SQL; | ||
@@ -30,0 +30,0 @@ sqlToQuery(sql: SQL): Query; |
@@ -102,3 +102,3 @@ "use strict"; | ||
} | ||
buildSelectQuery({ fields, where, table, joins, orderBy, limit, offset }) { | ||
buildSelectQuery({ fields, where, table, joins, orderBy, groupBy, limit, offset }) { | ||
const joinKeys = Object.keys(joins); | ||
@@ -130,6 +130,14 @@ const selection = this.buildSelection(fields, { isSingleTable: joinKeys.length === 0 }); | ||
}); | ||
const groupByList = []; | ||
groupBy.forEach((groupByValue, index) => { | ||
groupByList.push(groupByValue); | ||
if (index < groupBy.length - 1) { | ||
groupByList.push((0, drizzle_orm_1.sql) `, `); | ||
} | ||
}); | ||
const groupBySql = groupByList.length > 0 ? (0, drizzle_orm_1.sql) ` group by ${drizzle_orm_1.sql.fromList(groupByList)}` : undefined; | ||
const orderBySql = orderByList.length > 0 ? (0, drizzle_orm_1.sql) ` order by ${drizzle_orm_1.sql.fromList(orderByList)}` : undefined; | ||
const limitSql = limit ? (0, drizzle_orm_1.sql) ` limit ${limit}` : undefined; | ||
const offsetSql = offset ? (0, drizzle_orm_1.sql) ` offset ${offset}` : undefined; | ||
return (0, drizzle_orm_1.sql) `select ${selection} from ${table}${joinsSql}${whereSql}${orderBySql}${limitSql}${offsetSql}`; | ||
return (0, drizzle_orm_1.sql) `select ${selection} from ${table}${joinsSql}${whereSql}${groupBySql}${orderBySql}${limitSql}${offsetSql}`; | ||
} | ||
@@ -136,0 +144,0 @@ buildInsertQuery({ table, values, onConflict, returning }) { |
@@ -21,3 +21,2 @@ import { AnySQLiteColumn } from './columns'; | ||
onDelete(action: UpdateDeleteAction): this; | ||
build(table: AnySQLiteTable): ForeignKey; | ||
} | ||
@@ -24,0 +23,0 @@ export declare class ForeignKey { |
@@ -24,2 +24,3 @@ "use strict"; | ||
} | ||
/** @internal */ | ||
build(table) { | ||
@@ -26,0 +27,0 @@ return new ForeignKey(table, this); |
import { SQL } from 'drizzle-orm/sql'; | ||
import { AnySQLiteColumn } from './columns'; | ||
import { AnySQLiteTable } from './table'; | ||
interface IndexConfig { | ||
@@ -25,3 +24,2 @@ /** | ||
where(condition: SQL): this; | ||
build(table: AnySQLiteTable): Index; | ||
} | ||
@@ -28,0 +26,0 @@ export declare class Index { |
@@ -25,2 +25,3 @@ "use strict"; | ||
} | ||
/** @internal */ | ||
build(table) { | ||
@@ -27,0 +28,0 @@ return new Index(this.config); |
{ | ||
"name": "drizzle-orm-sqlite", | ||
"version": "0.12.0-beta.13", | ||
"version": "0.12.0-beta.14", | ||
"description": "Drizzle ORM package for SQLite database", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
import { Placeholder, Query, SQL, SQLWrapper } from 'drizzle-orm/sql'; | ||
import { AnySQLiteColumn } from '../columns'; | ||
import { SQLiteDialect } from '../dialect'; | ||
@@ -25,2 +26,3 @@ import { SelectResultFields, SQLiteSelectFields } from '../operations'; | ||
orderBy(...columns: SQL[]): Omit<this, 'where' | `${JoinType}Join` | 'orderBy'>; | ||
groupBy(...columns: (AnySQLiteColumn | SQL)[]): Omit<this, 'where' | `${JoinType}Join`>; | ||
limit(limit: number | Placeholder): Omit<this, 'where' | `${JoinType}Join` | 'limit'>; | ||
@@ -27,0 +29,0 @@ offset(offset: number | Placeholder): Omit<this, 'where' | `${JoinType}Join` | 'offset'>; |
@@ -30,2 +30,3 @@ "use strict"; | ||
orderBy: [], | ||
groupBy: [], | ||
}; | ||
@@ -77,2 +78,6 @@ this.joinsNotNullable = { [table[drizzle_orm_1.Table.Symbol.Name]]: true }; | ||
} | ||
groupBy(...columns) { | ||
this.config.groupBy = columns; | ||
return this; | ||
} | ||
limit(limit) { | ||
@@ -79,0 +84,0 @@ this.config.limit = limit; |
@@ -81,2 +81,3 @@ import { AnyColumn } from 'drizzle-orm'; | ||
orderBy: SQL[]; | ||
groupBy: (AnySQLiteColumn | SQL)[]; | ||
} | ||
@@ -83,0 +84,0 @@ export declare type JoinFn<TTable extends AnySQLiteTable, TInitialSelectResultFields extends SelectResultFields<SQLiteSelectFields<GetTableConfig<TTable, 'name'>>>, TStatement, TJoinType extends JoinType, TResult = undefined, TJoinsNotNullable extends Record<string, JoinNullability> = Record<GetTableConfig<TTable, 'name'>, 'not-null'>> = <TJoinedTable extends AnySQLiteTable, TSelect extends SQLiteSelectFields<string> = GetTableConfig<TJoinedTable, 'columns'>, TJoinedName extends GetTableConfig<TJoinedTable, 'name'> = GetTableConfig<TJoinedTable, 'name'>>(table: TJoinedTable, on: SQL, select?: TSelect) => SQLiteSelect<TTable, TInitialSelectResultFields, TStatement, AppendToResult<TResult, TJoinedName, TSelect>, AppendToJoinsNotNull<TJoinsNotNullable, TJoinedName, TJoinType>>; |
@@ -8,5 +8,2 @@ import { AnySQLiteColumn } from './columns'; | ||
constructor(name: string, column: AnySQLiteColumn); | ||
build(table: AnySQLiteTable<{ | ||
name: TTableName; | ||
}>): Unique<TTableName>; | ||
} | ||
@@ -13,0 +10,0 @@ export declare type AnyUniqueBuilder<TTableName extends string = string> = UniqueBuilder<TTableName>; |
@@ -9,2 +9,3 @@ "use strict"; | ||
} | ||
/** @internal */ | ||
build(table) { | ||
@@ -11,0 +12,0 @@ return new Unique(table, this); |
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
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
236824
3605