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;
return databaseInstance;
});
}
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'));
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(() => {
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())
);
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__) {
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')
deleteDatabase = () => {
this.updateProgress("Deleting database");
SQLite.deleteDatabase(database_name).then(() => {
console.log("Database DELETED");
this.updateProgress("Database DELETED")
}).catch((error) => {
this.errorCB(error);
});
};
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");
});
};
* 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}