mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 05:14:23 +00:00
add db reset to init
This commit is contained in:
@@ -61,6 +61,7 @@ if ( settings.setupDone ) {
|
|||||||
|
|
||||||
if ( !settings.init ) {
|
if ( !settings.init ) {
|
||||||
db.initDB();
|
db.initDB();
|
||||||
|
db.reset();
|
||||||
let mutSettings = settings;
|
let mutSettings = settings;
|
||||||
mutSettings[ 'init' ] = true;
|
mutSettings[ 'init' ] = true;
|
||||||
db.saveSettings( mutSettings );
|
db.saveSettings( mutSettings );
|
||||||
|
|||||||
@@ -36,6 +36,19 @@ module.exports.initDB = () => {
|
|||||||
} )();
|
} )();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.reset = () => {
|
||||||
|
console.log( '[ DB ] Resetting...' );
|
||||||
|
this.writeJSONData( 'booked', '{}' );
|
||||||
|
this.writeJSONData( 'eventDrafts', '{}' );
|
||||||
|
this.writeJSONData( 'events', '{}' );
|
||||||
|
this.writeJSONData( 'locations', '{}' );
|
||||||
|
this.writeJSONData( 'events', '{}' );
|
||||||
|
this.writeJSONData( 'rootAccount', '{}' );
|
||||||
|
this.writeJSONData( 'seatplan', '{}' );
|
||||||
|
this.writeJSONData( 'tickets', '{}' );
|
||||||
|
console.log( '[ DB ] Reset complete!' );
|
||||||
|
};
|
||||||
|
|
||||||
module.exports.getDataSimple = ( db, column, searchQuery ) => {
|
module.exports.getDataSimple = ( db, column, searchQuery ) => {
|
||||||
return new Promise( ( resolve, reject ) => {
|
return new Promise( ( resolve, reject ) => {
|
||||||
dbh.query( { 'command': 'getFilteredData', 'property': column, 'searchQuery': searchQuery }, dbRef[ db ] ).then( data => {
|
dbh.query( { 'command': 'getFilteredData', 'property': column, 'searchQuery': searchQuery }, dbRef[ db ] ).then( data => {
|
||||||
|
|||||||
Reference in New Issue
Block a user