Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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'));
static open() {
this.databaseName = 'sqlite.db';
SQLite.enablePromise(true);
return SQLite.openDatabase({ name: this.databaseName, createFromLocation: '~sqlite.db' }).then(db => {
console.log('[db] Database open!');
this.database = db;
return db;
});
}
'use strict';
import React, { Component } from 'react';
import { ListView, StyleSheet, Text, View } 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;
export default class SQLiteDemo extends Component {
constructor() {
super();
this.progress = [];
this.state = {
progress: [],
ds: new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2
'use strict';
import React, { Component } from 'react';
import {
StyleSheet,
Text,
View,
ListView,
Button
} 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;
export default class SQLiteDemo extends Component {
constructor() {
super();
this.progress = [];
this.state = {
progress: [],
ds: new ListView.DataSource({
rowHasChanged: (r1, r2) => r1 !== r2}