How to use react-native-sqlite-storage - 10 common examples

To help you get started, we’ve selected a few react-native-sqlite-storage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github blefebvre / react-native-sqlite-demo / src / database / Database.ts View on Github external
public open(): Promise {
    SQLite.DEBUG(true);
    SQLite.enablePromise(true);
    let databaseInstance: SQLite.SQLiteDatabase;

    return SQLite.openDatabase({
      name: DATABASE.FILE_NAME,
      location: "default"
    })
      .then(db => {
        databaseInstance = db;
        console.log("[db] Database open!");

        // Perform any database initialization or updates, if needed
        const databaseInitialization = new DatabaseInitialization();
        return databaseInitialization.updateDatabaseTables(databaseInstance);
      })
      .then(() => {
        this.database = databaseInstance;
        return databaseInstance;
      });
  }
github blefebvre / react-native-sqlite-demo / src / database / Database.ts View on Github external
public open(): Promise {
    SQLite.DEBUG(true);
    SQLite.enablePromise(true);
    let databaseInstance: SQLite.SQLiteDatabase;

    return SQLite.openDatabase({
      name: DATABASE.FILE_NAME,
      location: "default"
    })
      .then(db => {
        databaseInstance = db;
        console.log("[db] Database open!");

        // Perform any database initialization or updates, if needed
        const databaseInitialization = new DatabaseInitialization();
        return databaseInitialization.updateDatabaseTables(databaseInstance);
      })
      .then(() => {
        this.database = databaseInstance;
github prsn / redux-persist-sqlite-storage / examples / rn / ReduxPersistSQLiteExample / store.js View on Github external
import thunk from 'redux-thunk';
import todoReducer from './reducers/todo-reducers';
// import storage from 'redux-persist/lib/storage';
import SQLite from 'react-native-sqlite-storage';
import SQLiteStorage from 'redux-persist-sqlite-storage';

const storeEngine = SQLiteStorage(SQLite);
// import logger from 'redux-logger';
const logger = createLogger({
  collapsed: true,
  duration: true,
  logErrors: true
});

SQLite.DEBUG(true);
SQLite.enablePromise(true);


const persistConfig = {
  storage: storeEngine,
  debug: true
};
// const persistedReducer = persistReducer(persistConfig, todoReducer);
// let store = createStore(persistedReducer, {}, applyMiddleware([thunk, logger]));

const store = createStore(
  todoReducer,
  undefined,
  compose(applyMiddleware(thunk, logger),
  autoRehydrate())
);
const persistor = persistStore(store, {storage: storeEngine}, () => console.log('hi'));
github blefebvre / react-native-sqlite-demo / src / database / Database.ts View on Github external
public open(): Promise {
    SQLite.DEBUG(true);
    SQLite.enablePromise(true);
    let databaseInstance: SQLite.SQLiteDatabase;

    return SQLite.openDatabase({
      name: DATABASE.FILE_NAME,
      location: "default"
    })
      .then(db => {
        databaseInstance = db;
        console.log("[db] Database open!");

        // Perform any database initialization or updates, if needed
        const databaseInitialization = new DatabaseInitialization();
        return databaseInitialization.updateDatabaseTables(databaseInstance);
      })
      .then(() => {
github prsn / redux-persist-sqlite-storage / examples / rn / ReduxPersistSQLiteExample / store.js View on Github external
import {createLogger} from 'redux-logger';
import thunk from 'redux-thunk';
import todoReducer from './reducers/todo-reducers';
// import storage from 'redux-persist/lib/storage';
import SQLite from 'react-native-sqlite-storage';
import SQLiteStorage from 'redux-persist-sqlite-storage';

const storeEngine = SQLiteStorage(SQLite);
// import logger from 'redux-logger';
const logger = createLogger({
  collapsed: true,
  duration: true,
  logErrors: true
});

SQLite.DEBUG(true);
SQLite.enablePromise(true);


const persistConfig = {
  storage: storeEngine,
  debug: true
};
// const persistedReducer = persistReducer(persistConfig, todoReducer);
// let store = createStore(persistedReducer, {}, applyMiddleware([thunk, logger]));

const store = createStore(
  todoReducer,
  undefined,
  compose(applyMiddleware(thunk, logger),
  autoRehydrate())
);
github longlongago2 / react-native-sqlite-helper / sqliteHelper.js View on Github external
import SQLiteStorage from 'react-native-sqlite-storage';

SQLiteStorage.DEBUG(__DEV__);       // 启动调试信息
SQLiteStorage.enablePromise(true);  // 使用 promise(true) 或者 callback(false)

export default class SQLite {
    static delete(database) {
        return SQLiteStorage.deleteDatabase(database)
            .then(res => ({ res }))
            .catch(err => ({ err }));
    }

    constructor(databaseName, databaseVersion, databaseDisplayName, databaseSize) {
        this.databaseName = databaseName;
        this.databaseVersion = databaseVersion;
        this.databaseDisplayName = databaseDisplayName;
        this.databaseSize = databaseSize;
        this.successInfo = (text, absolutely) => {
            if (__DEV__) {
github gyxing / react-native-book / app / db / SQLite.js View on Github external
import React, { Component } from 'react'
import SQLiteStorage from 'react-native-sqlite-storage'

SQLiteStorage.DEBUG(false)
const database_name = 'reader.db'
const database_version = '1.0'
const database_displayname = 'ReaderSQLite'
const database_size = -1
let db
const Book_TABLE_NAME = 'Book' // 书架表
const Chapter_TABLE_NAME = 'Chapter' // 目录表

export default class SQLite extends Component {
  constructor() {
    super()
  }

  componentWillUnmount() {
    if (db) {
      this._successCB('close')
github andpor / react-native-sqlite-storage / test / index.ios.promise.js View on Github external
deleteDatabase = () => {
    this.updateProgress("Deleting database");
    SQLite.deleteDatabase(database_name).then(() => {
      console.log("Database DELETED");
      this.updateProgress("Database DELETED")
    }).catch((error) => {
      this.errorCB(error);
    });
  };
github andpor / react-native-sqlite-storage / test / index.ios.promise.js View on Github external
loadAndQueryDB = () => {
    this.updateProgress("Plugin integrity check ...");
    SQLite.echoTest().then(() => {
      this.updateProgress("Integrity check passed ...");
      this.updateProgress("Opening database ...");
      SQLite.openDatabase(database_name, database_version, database_displayname, database_size).then((DB) => {
        db = DB;
        this.updateProgress("Database OPEN");
        this.populateDatabase(DB);
      }).catch((error) => {
        console.log(error);
      });
    }).catch(error => {
      this.updateProgress("echoTest failed - plugin not functional");
    });
  };
github andpor / react-native-sqlite-storage / test / index.ios.callback.js View on Github external
* See http://opensource.org/licenses/alphabetical for full text.
 */
'use strict';

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  ListView
} from 'react-native';


import SQLite from 'react-native-sqlite-storage';
SQLite.DEBUG(true);
SQLite.enablePromise(false);

const database_name = "Test.db";
const database_version = "1.0";
const database_displayname = "SQLite Test Database";
const database_size = 200000;
let db;

class SQLiteDemo extends Component {
  constructor() {
    super();
    this.progress = [];
    this.state = {
      progress: [],
      ds: new ListView.DataSource({
        rowHasChanged: (r1, r2) => r1 !== r2}

react-native-sqlite-storage

SQLite3 bindings for React Native (Android & iOS)

MIT
Latest version published 3 years ago

Package Health Score

58 / 100
Full package analysis