New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-native-sql-query-builder

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-sql-query-builder

An SQL query builder. It executes built queries if an executing function is set.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-90%
Maintainers
1
Weekly downloads
 
Created
Source

Warning

This package is deprecated and, most probably, no longer functioning due to changes in packages it depends on. Please use simple-sql-query-builder instead.

An SQL query builder for RN projects. It executes built queries if an executing function is set.

Usage

  1. SqlBuilder
  2. TableBuilder
  3. Column
  4. UniqueBuilder
SqlBuilder

This is the "entry point" of the builder. It contains only static methods and fields.

import SqlBuilder from "react-native-sql-query-builder";
  1. setDebug()
  2. setSqlExecutor()
  3. executeSql()
  4. createTable()
  • setDebug()

    Turns on or off the debug mode. In debug mode each executed sql statement is logged to the console.

     SqlBuilder.setDebug(debug);
    
  • setSqlExecutor()

    Sets a function to be used to execute sql statements.

     import SQLite from "react-native-sqlite-storage";
     
     ...
     
     const db = await SQLite.openDatabase(...);
     
     SqlBuilder.setSqlExecutor(db.executeSql.bind(db));
    
  • executeSql()

    Executes an sql statement by invoking a function set by setSqlExecutor(). It returns the result of that function invocation or simply the passed sql statement if setSqlExecutor hasn't been called.

    The result of invoking this method is returned from the CRUD methods.

     SqlBuilder.executeSql("some sql code);
    
  • createTable()

    Creates a table using TableBuilder.

     const name = "weights";
     
     const callback = tableBuilder => {
         tb.integer("rowid").primary();
         tb.integer("millis").notNull();
         tb.integer("gross").notNull();
         tb.integer("net").notNull();
         tb.text("comment").notNull();
     };
     
     const ifNotExists = Boolean; // Adds "IF NOT EXISTS" if true. Default: true.
     
     SqlBuilder.createTable(name, callback, ifNotExists);
    
TableBuilder
  • column()

    Creates a Column and returns it to allow method chaining.

     tb
         .column(
             name: "rate",
             type: "REAL")
         .notNull();
    

    There are shorthands for the INTEGER, TEXT and BLOB types:

     tb.integer("rowid").primary();
     tb.text("comment").notNull();
     tb.blob("image");
    
  • unique()

    Makes a column unique using UniqueBuilder.

     tb.unique(ub => {
         ub
             .column("name")
             .collate("NOCASE")
             .order("ASC");
         
         ub
             .column("code")
             .collate("NOCASE")
             .order("ASC");
     });
    
Column
  • primary()

    Adds PRIMARY KEY to this column definition.

  • foreign()

    Adds REFERENCES tableName(columnName) to this column definition.

     tb.integer("type").foreign("tableName", "columnName");
    
  • onDelete()

    Adds ON DELETE action to this column definition.

     tb.integer("journeyRowid")
         .foreign("tableName", "column name")
         .onDelete("action");
    
  • notNull()

    Adds NOT NULL to this column definition.

UniqueBuilder
  • column()

    Specifies the unique column name and optionally collation and order.

     ub
         .column("code")
         .collate("NOCASE")
         .order("ASC");
    

Version history

Version numberChanges
v1.0.0Initial release.


Written with StackEdit.

Keywords

FAQs

Package last updated on 29 Aug 2017

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