Releases: wsporto/typesql
v0.15.3
New Features
Dynamic Query Support for PostgreSQL
TypeSQL now supports Dynamic Queries for PostgreSQL. By adding the @dynamicQuery
annotation to your SQL, TypeSQL generates a function with parameters to dynamically construct queries. The final SQL will include only the necessary JOINS, CTEs, and SELECT columns based on the provided parameters.
Example Usage:
- SQL Query with
@dynamicQuery
annotation:
-- @dynamicQuery
SELECT *
FROM Products
- You can now dynamically select columns and apply filters in a type-safe manner using the generated function.
const products = await selectProducts(conn, {
select: {
ProductID: true,
ProductName: true,
UnitPrice: true,
},
where: [["ProductName", "LIKE", productNameLike]],
});
Full Changelog: v0.15.2...v0.15.3
v0.15.2
New Features
Postgres
Nested Query Result Support
With this release, TypeSQL now supports Nested Query Result for PostgreSQL.
If you want to generate a nested query result, you must annotate the query with @nested
in a SQL comment:
-- @nested
SELECT
*
FROM users
INNER JOIN posts ON posts.user_id = users.id
Once the query is annotated, TypeSQL will automatically generate the appropriate nested type:
const result = await selectUserPostsNested(conn);
// Result type:
const result: {
id: number;
name: string;
posts: {
id: number;
title: string;
body: string;
}[];
}[];
Full Changelog: v0.15.1...v0.15.2
v0.15.1
New Features
Postgres
* Automatic CRUD generation
With this release, TypeSQL now supports automatic CRUD generation for PostgreSQL databases.
By including the includeCrudTables
option in your typesql.json configuration file, TypeSQL will automatically generate functions for CRUD (Create, Read, Update, Delete) operations for the specified tables.
Example:
{
"databaseUri": "postgres://postgres:[email protected]:5432/postgres",
"sqlDir": "./src/sql",
"client": "pg",
"includeCrudTables": ["books"]
}
In this example, TypeSQL will generate the following functions for the books
table:
insertIntoBooks(...)
selectFromBooks(...)
updateBooks(...)
deleteFromBooks(...)
These functions allow you to easily interact with the books
table and perform common CRUD operations without manually writing SQL queries.
Full Changelog: v0.15.0...v0.15.1
v0.15.0
New Features:
- Experimental Support for PostgreSQL:
This release adds experimental support for PostgreSQL (pg driver).
Please note that this feature is still in the experimental phase and may have limited functionality or contain bugs. We encourage users to test it and provide feedback.
How to configure:
To configure TypeSQL for PostgreSQL, use a configuration file (typesql.json
) as shown in the example below:
{
"databaseUri": "postgres://postgres:[email protected]:5432/postgres",
"sqlDir": "./src/sql",
"client": "pg"
}
Full Changelog: v0.14.3...v0.15.0
v0.14.3
v0.14.2
v0.14.1
What's Changed
SQLite:
- Added support for pipe operator (
||
) - Added support for
trim
,ltrim
,rtrim
andreplace
functions - Allow usage of column alias in WHERE expression
Full Changelog: v0.14.0...v0.14.1
v0.14.0
New Features:
- Added initial support for JSON functions.
Supported JSON Functions:
Scalar functions:
json
jsonb
json_array
jsonb_array
json_array_length
json_error_position
json_extract
jsonb_extract
Table-valued functions:
json_each
json_tree
Full Changelog: v0.13.1...v0.14.0
v0.13.1
v0.13.0
What's Changed
As of this release, index.ts
now exports modules with the .js
extension by default.
Before:
export * from "./select-users";
export * from "./select-posts";
After:
export * from "./select-users.js";
export * from "./select-posts.js";
You can configure the file extension for module exports via the moduleExtension
property in the typesql.json
configuration file.
Property:
"moduleExtension": "ts" | "js"
Example Configuration:
{
"moduleExtension": "ts"
}
This will make the index.ts
file export with .ts
extensions(e.g., export * from './select-users.ts'
), instead of the default .js.
Full Changelog: v0.12.0...v0.13.0