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

typesql-cli

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typesql-cli - npm Package Compare versions

Comparing version 0.6.6 to 0.6.7

3

describe-nested-query.js

@@ -71,3 +71,4 @@ "use strict";

const result = parentList.map(r => {
const relationFields = relations.filter(r2 => r2.parent.name == r.name || r2.parent.alias == r.alias).map(f => {
const relationFields = relations.filter(r2 => r2.parent.name == r.name || (r.alias != '' && r2.parent.alias == r.alias))
.map(f => {
const field = {

@@ -74,0 +75,0 @@ type: 'relation',

{
"name": "typesql-cli",
"version": "0.6.6",
"version": "0.6.7",
"description": "",

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

@@ -5,4 +5,5 @@ import { Either } from "fp-ts/lib/Either";

export declare class DbClient {
private connection;
private pool;
mySqlVersion: string;
database: string;
connect(connectionUri: string): Promise<Either<TypeSqlError, true>>;

@@ -9,0 +10,0 @@ closeConnection(): Promise<void>;

@@ -23,5 +23,7 @@ "use strict";

try {
this.connection = yield (0, promise_1.createConnection)(connectionUri);
const [rows] = yield this.connection.execute("select @@version as version");
this.pool = yield (0, promise_1.createPool)(connectionUri);
const [rows] = yield this.pool.execute("select @@version as version");
this.mySqlVersion = rows[0].version;
//@ts-ignore
this.database = this.pool.pool.config.connectionConfig.database;
return (0, Either_1.right)(true);

@@ -40,4 +42,4 @@ }

return __awaiter(this, void 0, void 0, function* () {
if (this.connection != null) {
this.connection.end();
if (this.pool != null) {
this.pool.end();
}

@@ -59,4 +61,4 @@ });

`;
if (this.connection != null) {
return this.connection.execute(sql, [this.connection.config.database])
if (this.pool != null) {
return this.pool.execute(sql, [this.database])
.then(res => {

@@ -86,4 +88,4 @@ const columns = res[0];

`;
if (this.connection) {
return this.connection.execute(sql, [this.connection.config.database, tableName])
if (this.pool) {
return this.pool.execute(sql, [this.database, tableName])
.then(res => {

@@ -107,7 +109,10 @@ const columns = res[0];

return __awaiter(this, void 0, void 0, function* () {
if (this.connection) {
//@ts-ignore
return this.connection.prepare(sql)
if (this.pool) {
const conn = yield this.pool.getConnection();
return conn.prepare(sql)
.then(() => {
return (0, Either_1.right)(true);
}).finally(() => {
var _a;
(_a = this.pool) === null || _a === void 0 ? void 0 : _a.releaseConnection(conn);
}).catch((err) => this.createInvalidSqlError(err));

@@ -114,0 +119,0 @@ }

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

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.
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.

@@ -6,4 +6,5 @@ ## Example

Having the following query in `select-products.sql` file.
```sql
SELECT
SELECT
id,

@@ -17,3 +18,3 @@ product_name,

TypeSQL will generate the types and function in the file `select-products.ts`.
TypeSQL will generate the types and function in the file `select-products.ts`.
Then you can import the generate code and execute as following:

@@ -29,3 +30,3 @@

- **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 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`.

@@ -40,3 +41,3 @@ - **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`;

1. *npm install -g typesql-cli*
1. _npm install -g typesql-cli_

@@ -47,5 +48,5 @@ 2. 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"
"databaseUri": "mysql://root:password@localhost/mydb",
"sqlDir": "./sqls",
"target": "node"
}

@@ -84,2 +85,3 @@ ```

# Examples
[Query scaffolding](/docs/query_scaffolding.md)

@@ -97,6 +99,8 @@

[Nested Query Result](/docs/nested-query-result.md)
# Project status
**WARNING:** This is a WIP experimental project. It is under active development and its API might change.
**WARNING:** This is a WIP experimental project. It is under active development and its API might change.
Issues reports and feature requests are welcome.

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