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

github.com/jasperalani/mysql-query-builder

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/jasperalani/mysql-query-builder

  • v0.0.0-20220302143916-c46620138480
  • Source
  • Go
  • Socket score

Version published
Created
Source

MySQL Query Builder

Functions that take values and return SQL ready to be queried.

Languages

  • Javascript
  • Typescript
  • Go - In progress
  • PHP - In progress

In the future:

  • Python

Functions

select insert update delete

condition.where

Todo

  • Make the functions more intuitive and simple (especially typescript)
  • Not all Go functions are working
  • Not all PHP functions have been created
  • Create test files
  • Improve typescript variable structure
  • Think about more languages to implement in

Usage

Javascript:

let query = ''

queryBuilder.select(['id', 'name'], 'my_table', 'id = 6');
queryBuilder.select(['id', 'name'], 'my_table', condition.where('id', '6', '='));
// SELECT id, name FROM `my_table` WHERE id = 6;

queryBuilder.insert(['name', 'deleted'], ['Jasper', false], 'my_table');
// INSERT INTO `my_table` (name, deleted) VALUES ('Jasper', 'false');

queryBuilder.update(['name', 'deleted'], ['Yasper', true], 'id = 6', 'my_table');
// UPDATE `my_table` SET name = 'Yasper', deleted = 'true' WHERE id = 6;

queryBuilder.delete('id = 6', 'my_table');
// DELETE FROM `my_table` WHERE id = 6;

queryBuilder.select(
  '*',
  'table',
  // condtion funtion
  condition.where(['id', 'code'], ['5', 'xxyyzz'], '=')
)
// SELECT * FROM `table` WHERE id = 5 AND code = 'xxyyzz';

Typescript:

const columns: Columns = {
    columns: [
        {value: 'id'},
        {value: 'name'},
        {value: 'deleted'}
    ]
}

const values: Values = {
    values: [
        {value: 6},
        {value: 'value'},
        {value: false}
    ]
}

queryBuilder.insert(columns, values, 'my_table');

queryBuilder.select(columns, 'my_table', 'id = 6');

queryBuilder.update(columns, values, 'id = 6', 'my_table');

queryBuilder.delete('id = 6', 'my_table');

PHP:

$builder = new QueryBuilder();

$select = $builder->select( [ 'column1', 'column2' ], 'table1', 'x = 6' );
$insert = $builder->insert( [ 'column1' ], ['value1'], 'table1' );
$update = $builder->update( [ 'column1', 'column2' ], ['value1', 'value2'], 'table1', 'x = 6' );
$delete = $builder->delete( 'table1', 'x = 6' );

FAQs

Package last updated on 02 Mar 2022

Did you know?

Socket

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.

Install

Related posts

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