@gallink/sequence
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Sequence

Sequence is a versatile SQL string builder built with the a fluid API in mind -- each builder is chainable, and can be interpolated into template literals. Using the ISequenceBuilder implementations such as Select, you can build any SQL statement to suit your needs -- if not, the entire library has been designed by interface allowing extension in any way you can think of.

Usage

To use this in your project, follow the simple examples below

SELECT Statements

// Create your column.
const column: ISequenceColumn = new SequenceColumn(Predicate.None, "username");

// Build your statement.
const select: ISequenceBuilder = new Select()
    .from("user")
    .where(column, LogicalOperator.Equality, "Crowes");

// Stringify your statement.
const sql: string = select.stringify();
// SELECT * FROM user WHERE userName = 'Crowes'

INSERT Statements

// Create your columns.
const columnA: ISequenceColumn = new SequenceColumn(Predicate.None, "username")
const columnB: ISequenceColumn = new SequenceColumn(Predicate.None, "password")

// Build your statement
const insert: ISequenceBuilder = new Insert()
    .into("user", columnA, columnB)
    .values("Crowes", 1234);

// Stringify your statement.
const sql: string = insert.stringify();
// INSERT INTO user (userName, userPassword) VALUES ('crowes', 1234)

DELETE Statements

// Create your column.
const column: ISequenceColumn = new SequenceColumn(Predicate.None, "username");

// Build your statement.
const delete: ISequenceBuilder = new Delete()
    .from("user")
    .where(column, LogicalOperator.Equality, "Crowes");

// Stringify your statement.
const sql: string = select.stringify();
// SELECT * FROM user WHERE userName = 'Crowes'

Readme

Keywords

Package Sidebar

Install

npm i @gallink/sequence

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

1.65 MB

Total Files

323

Last publish

Collaborators

  • crowes