Socket
Socket
Sign inDemoInstall

universal-query

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    universal-query

This is a pure javascript query builder for NodeJS supporting mysql and mongo out of the box.


Version published
Weekly downloads
4
decreased by-20%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Universal Query

Build Status Code Climate Coverage Status Author

An pure javascript query builder for various databases.

Currently supported:

  • MySQL
  • MongoDB

The API

The API is for all the query builders the same.
This is done so you can easily change the database type, and the queries work like normal.

Although keep the database limitations in mind.

Documentation

All example can be used in MySQL and MongoDB only by changing the getType value. Supported values are:

  • mysql
  • mongo

Building a simple mysql select query.

var universal_query = require('universal-query');

var mysql = universal_query.getType('mysql');
var sql = mysql.select().table('foo').toQuery();
// SELECT * FROM `foo`;

A more advanced select query

var universal_query = require('universal-query');

var mysql = universal_query.getType('mysql');
var sql = mysql.select().table('foo', 'bar').where('bar.foo_bar', '=', 1).toQuery();
// SELECT * FROM `foo` AS `bar` WHERE `bar`.`foo_bar` = 1;

An insert query

var universal_query = require('universal-query');

var mysql = universal_query.getType('mysql');
var sql = mysql.insert().table('foo').set('foo', 'bar').toQuery();
// INSERT INTO `foo` (`foo`) VALUES ('bar');

An update query

var universal_query = require('universal-query');

var mysql = universal_query.getType('mysql');
var sql = mysql.update().table('foo').set('foo', 'bar').where('foo.foo_bar', '=', 1).toQuery();
// UPDATE `foo` SET `foo`='bar' WHERE `foo`.`foo_bar` = 1;

Keywords

FAQs

Last updated on 20 Dec 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc