Files
lnreader/src/database/DBHelper.js
T
Marcin Majewski 33ceb60850 eslint quick-fix (#87)
* fix(github-check): Catch github connection errors

* fix(eslint): fixed eslint warnings and errors

Fixed every eslint warning and error that wasn't one of the following:
- react-hooks/exhaustive-deps
- no-console

Added .vscode to .gitignore
Added no-console:warn to eslintrc

* fix(gradlew): set file to runnable (chmod 755)

* remove .vscode
2021-10-15 18:42:40 +05:30

58 lines
1.4 KiB
JavaScript

import * as SQLite from 'expo-sqlite';
import {
createNovelTableQuery,
createUrlIndexQuery,
createLibraryIndexQuery,
} from './tables/NovelTable';
import {
createChapterTableQuery,
createNovelIdIndexQuery,
createUnreadChaptersIndexQuery,
} from './tables/ChapterTable';
import {
createHistoryTableQuery,
createChapterIdIndexQuery,
} from './tables/HistoryTable';
import {createDownloadTableQuery} from './tables/DownloadTable';
import {
createUpdatesTableQuery,
// updatesSeedDataQuery,
} from './tables/UpdateTable';
/**
* Database Version = 2
*/
const dbName = 'lnreader.db';
const db = SQLite.openDatabase(dbName);
export const createDB = () => {
db.transaction(tx => {
tx.executeSql(createNovelTableQuery);
tx.executeSql(createChapterTableQuery);
tx.executeSql(createHistoryTableQuery);
tx.executeSql(createDownloadTableQuery);
tx.executeSql(createUpdatesTableQuery);
/**
* Indexes
*/
tx.executeSql(createUrlIndexQuery);
tx.executeSql(createLibraryIndexQuery);
tx.executeSql(createNovelIdIndexQuery);
tx.executeSql(createUnreadChaptersIndexQuery);
tx.executeSql(createChapterIdIndexQuery);
});
};
export const deleteDb = () => {
db.transaction(tx => {
tx.executeSql('DROP TABLE novels');
tx.executeSql('DROP TABLE chapters');
tx.executeSql('DROP TABLE history');
tx.executeSql('DROP TABLE downloads');
tx.executeSql('DROP TABLE updates');
});
};