blaanteam / ts-sql-builder Goto Github PK
View Code? Open in Web Editor NEWSQL query & schema generator for Node.js
Home Page: https://www.npmjs.com/package/ts-sql-builder
License: MIT License
SQL query & schema generator for Node.js
Home Page: https://www.npmjs.com/package/ts-sql-builder
License: MIT License
enhancement
Seperate code in /lib/query-builder.ts
enhancement
Add unit & e2e tests, as well as usage examples
enhancement / feature request
Here, instead of having fields as an array of column names, allow optional alias for selected columns
Update these methods and this part accordingly.
It's a better idea to create an automated schema builder.
Kind of like ORMs (typeorm entities for instane), I'd like to automatically generate sql table schemas just from a class. This way, when I fetch data from a table I know for sure it can fit into a class (from which I generated the table schema).
None, the main solution seems doable & perfect!
Idea:
This code:
@Table('users')
class User {
@PrimaryKey()
@Column({ type: 'SERIAL' })
id!: number;
@Column({ type: 'VARCHAR(255)', nullable: false })
name!: string;
@Column({ type: 'VARCHAR(65)', nullable: false, unique: true })
username!: string;
@Column({ type: 'INTEGER', check: 'age >= 18' })
age!: number;
@Column({ type: 'VARCHAR(255)', unique: true })
email!: string;
@Column({
name: 'created_at',
type: 'TIMESTAMP',
default: () => 'CURRENT_TIMESTAMP',
})
createdAt!: Date;
@Column({ type: 'BOOLEAN', default: true })
activated!: boolean;
}
Generates this schema:
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
username VARCHAR(65) UNIQUE NOT NULL,
age INTEGER CHECK (age >= 18),
email VARCHAR(255) UNIQUE,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
activated BOOLEAN DEFAULT true
);
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
This repository currently has no open or pending branches.
package.json
nodemon ^3.0.2
ts-node ^10.9.2
Docs
/**
* Add columns to the SELECT clause of the SQL query.
* @param selection A column name, a record of columns-aliases, or an array containing a mix both.
* @param fromTable Optional. If specified, all selected columns are prefixed with 'fromTable.'.
* @returns The current instance of the QueryBuilder for method chaining.
*/
select(...)
Feature request
Support other crud queries:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.