Giter Club home page Giter Club logo

queryforge's Introduction

QueryForge

QueryForge is a TypeScript library that provides a flexible and type-safe way to compose SQL queries dynamically. With QueryForge, you can easily construct SELECT, INSERT, UPDATE, and DELETE queries using TypeScript code.

Link: https://playcode.io/1817024

Usage

import QueryComposer from 'queryforge';

interface Casa {
  quartos: number;
  bairro: string;
  rua: string;
}

// Create an instance of QueryComposer with the desired type
const queryComposer = new QueryComposer<Casa>();

// Example: Generating a SELECT query
const selectQuery = queryComposer
  .startSelection('Casa')
  .Select('quartos', 'bairro', 'rua')
  .Where((item) => {
    return item.quartos > 2 && item.bairro === '1';
  })
  .toString();
console.log(selectQuery);
// Output: SELECT quartos, bairro, rua FROM Casa WHERE quartos > 2 AND bairro = '1';

// Example: Generating an INSERT query
const insertQuery = queryComposer
  .startInsertion('Casa')
  .Insert('bairro', 'Paulista')
  .Insert('quartos', 3)
  .toString();
console.log(insertQuery);
// Output: INSERT INTO Casa SET (bairro, quartos) VALUES ('Paulista',3);

// Other examples for UPDATE and DELETE queries are also available.

API Documentation

QueryComposer<T>

The main class responsible for composing SQL queries. It accepts a type parameter T representing the schema of the table.

Methods:

  • startSelection(entity: string): ConstructorQuerySelectable<T>: Initialize a SELECT query for the specified entity.
  • startUpdation(entity: string): ConstructorQueryUpdatable<T>: Initialize an UPDATE query for the specified entity.
  • startDeletion(entity: string): ConstructorQueryDeletable<T>: Initialize a DELETE query for the specified entity.
  • startInsertion(entity: string): ConstructorQueryInsertable<T>: Initialize an INSERT query for the specified entity.

License

This library is licensed under the MIT License. See the LICENSE file for details.

Contributions

Contributions are welcome! If you find any issues or have suggestions, feel free to open an issue or create a pull request on GitHub.

Authors

Support

For any inquiries or support, please contact [email protected].

Acknowledgements

Special thanks to the developers and contributors of TypeScript, Jest, and other dependencies used in this project.

Version History

  • 1.0.0 (YYYY-MM-DD): Initial release.

Keywords

TypeScript, SQL, Query Builder, Dynamic Queries, Database, Jest

Related Projects

Feel free to add any additional sections or modify the content according to your project's specific requirements.

queryforge's People

Contributors

felpereira avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.