Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
typesql-cli
Advanced tools
TypeSQL: An alternative to access MySQL databases without an ORM. Write your queries in raw SQL and TypeSQL will generate a type-safe API to execute the queries.
Readme
TypeSQL: An alternative to access MySQL databases without an ORM. Write your queries in raw SQL and TypeSQL will generate a type-safe API to execute the queries.
Having the following query in select-products.sql
file.
SELECT
id,
product_name,
list_price
FROM products
WHERE discontinued = 0
AND list_price BETWEEN :minPrice AND :maxPrice
TypeSQL will generate the types and function in the file select-products.ts
.
Then you can import the generate code and execute as following:
deno syntax:
Do not restrict the use of SQL You dont need to learn any new query language, you can use SQL with all its power and expressiveness.
Infer parameters and columns types. SELECT DATEDIFF(:date1, :date2) as days_stayed
will resolve the date1
and date2
parameters to the type Date
and the function return type as number
.
Infer parameter and column nullability. The nullable database column email
will generate a nullable field for the query SELECT email FROM mytable
, but will generate a non-nullable field for the query SELECT email FROM mytable WHERE email is not null
;
Infer the query return type (single row vs multiple rows). If the id
is a primary key or unique key, then function for the query SELECT * FROM Books where id = :id
will return Book|null
, instead of Book[]
. The same is true for filters with LIMIT 1;
Allow the use of dynamic ORDER BY with auto-completion and compile-time verification. See here.
npm install -g typesql-cli
Add the typesql.json
configuration file in project root folder. You can generate an template with cli command typesql init
.
{
"databaseUri": "mysql://root:password@localhost/mydb",
"sqlDir": "./sqls",
"target": "node"
}
sqls\
select-products.sql
insert-product.sql
update-product.sql
typesql compile --watch
to start typesql in watch mode. After that you will have one Typescript file for each query file.sqls\
select-products.sql
select-products.ts
insert-product.sql
insert-product.ts
update-product.sql
update-product.ts
const products = await selectProducts(...
const updateResult = await updateProduct(...
WARNING: This is a WIP experimental project. It is under active development and its API might change.
Issues reports and feature requests are welcome.
FAQs
TypeSQL: An alternative to access MySQL databases without an ORM. Write your queries in raw SQL and TypeSQL will generate a type-safe API to execute the queries.
The npm package typesql-cli receives a total of 71 weekly downloads. As such, typesql-cli popularity was classified as not popular.
We found that typesql-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.