Created
April 1, 2020 15:31
-
-
Save infinitbility/dd49dc8e3bb02575a52d19f1209f63e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import SQLite from 'react-native-sqlite-storage'; | |
export default class SQLiteScreen extends React.Component { | |
constructor() { | |
super(); | |
SQLite.DEBUG = true; | |
} | |
/** | |
* Execute sql queries | |
* | |
* @param sql | |
* @param params | |
* | |
* @returns {resolve} results | |
*/ | |
ExecuteQuery = (sql, params = []) => new Promise((resolve, reject) => { | |
db.transaction((trans) => { | |
trans.executeSql(sql, params, (trans, results) => { | |
resolve(results); | |
}, | |
(error) => { | |
reject(error); | |
}); | |
}); | |
}); | |
/** | |
* Delete Query Example | |
*/ | |
async DeleteQuery(){ | |
let deleteQuery = await this.ExecuteQuery('DELETE FROM users WHERE id = ?', [4]); | |
console.log(deleteQuery); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment