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

expo-sqlite-query-helper

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-sqlite-query-helper

SQLite query helper library for expo-sqlite

  • 1.0.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

expo-sqlite Query Helper 🦮

SQLite query helper library for expo-sqlite

Installation

Yarn

yarn add expo-sqlite-query-helper

NPM

npm install --save expo-sqlite-query-helper

Usage

import { useEffect } from "react";
import Database, { createTable, insert } from "expo-sqlite-query-helper";

const App = () => {
  const db = Database("myDatabase.db");

  useEffect(() => {
    createTable("user", {
      name: "TEXT",
      email: "TEXT",
    }).then((row, rowAffected, insertID) =>
      console.log("success", row, rowAffected, insertID)
    );
    insert([{ name: "Jhon", email: "jhon@test.com" }], "user")
      .then((row, rowAffected, insertID) => {
        console.log("success", row, rowAffected, insertID);
      })
      .catch((e) => console.log(e));
  }, []);
};

API

Initialize

import Database from "expo-sqlite-query-helper";

Database("database_name.db");

Create Table

Async function to create new table.
under the hood it runs CREATE TABLE IF NOT EXIST.

import { createTable } from "expo-sqlite-query-helper";
createTable(tableName: string, columns: { [key: string]: string });

tableName - Name of the table to create.
columns - Column object, key is name of column, value is type & other arguments for columns (as per sqlite).

Insert

Async function to run insert query, Takes array of objects to insert into specified table.
under the hood it runs INSERT INTO table (...columns) values(...values1), (...values2);

import { insert } from "expo-sqlite-query-helper";
insert(table: string, data: InsertObject[]);

tableName - Name of the table to insert data.
data - array of objects to insert into table.
example: [{name:"test1",email:"test1@emmail.com"},{name:"test2",email:"test2@exmail.com"}].
Return promise resolving with rowsAffected, insertId

Keywords

FAQs

Package last updated on 10 Sep 2020

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