npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ionix-sqlite-batch

v0.1.4

Published

Makes it easier to use SQLite in your Ionic 3 app

Downloads

5

Readme

Ionix SQLite

This project aims to make it easier to work with SQLite in Ionic 2 apps.

As it has no actual dependencies on Ionic it could be used in other Cordova applications as well.

In case you wonder, Ionix stands for "Ionic eXtensions". It's a name chosen to suggest that this package is related to Ionic, but is not an official Ionic project.

Why not just use Ionic Native?

Ionic Native is a wonderful project that wraps many useful Cordova plugins including SQLite.

However this project offers a few more features in addition to wrapping the Cordova SQLite plugin:

  • It works in the browser (both ionic serve and ionic run browser) and not just on Android/iOS/Windows, by defaulting to WebSQL when the Cordova plugin is not available. (Note: the WebSQL standard is deprecated and support for it may be removed from Chrome at some point. Not a big deal, it works for now and we'll figure out a workaround if and when we need to.)
  • No need to wait for deviceready or Platform.ready(); this is handled for you.
  • When opening a database you can speficy one or more SQL statements to e.g. create all the required tables, and it will return a Promise that resolves only when the db has been fully initialised.
  • This project works with either the cordova-sqlite-storage or the cordova-plugin-sqlite-2 plugins. Install whichever you prefer.

Usage

Install with npm:

npm install --save ionix-sqlite-batch

Import and use a follows:

import { SqlDatabase } from 'ionix-sqlite-batch';
import { Item } from './item.model';

export class ItemService {

  private dbPromise: Promise<SqlDatabase>;

  constructor() {
    const createItemsTable = `
      CREATE TABLE IF NOT EXISTS items (
        id INTEGER PRIMARY KEY,
        title TEXT,
        description TEXT
      )
    `;
    this.dbPromise = SqlDatabase.open('items.db', [createItemsTable]);
  }

  getItems(): Promise<Item[]> {
    const select = 'SELECT id, title, description FROM items';
    return this.dbPromise
      .then(db => db.execute(select))
      .then(resultSet => {
        const items = [];
        for (let i = 0; i < resultSet.rows.length; i++) {
          const row = resultSet.rows.item(i);
          items.push({
            id: row.id,
            title: row.title,
            description: row.description
          });
        }
        return items;
      });
  }


  insertItems(): Promise<any> {
    let inserts: any = [
      'INSERT INTO items (id, title) VALUES ("1", "title A");',
      'INSERT INTO items (id, title) VALUES ("2", "title B");',
      'INSERT INTO items (id, title) VALUES ("3", "title C");'
    ];
    return this.dbPromise
      .then(db => db.executeBatch(inserts))
      .then(() => {
        console.log('Done!');
      }).catch( err => console.log(err) );
  }
  

}