mirror of
https://github.com/janishutz/libreevent.git
synced 2025-11-25 13:24:24 +00:00
move db to a more accessible folder
This commit is contained in:
@@ -1 +0,0 @@
|
||||
{"test4":{"secAr4s7":{"id":"secAr4s7","component":1,"ticketOption":"1","eventID":"test4","category":"1","name":"Row 5, Seat 8"},"secAr6s14":{"id":"secAr6s14","component":1,"ticketOption":"2","eventID":"test4","category":"1","name":"Row 7, Seat 15"},"secAr6s10":{"id":"secAr6s10","component":1,"ticketOption":"2","eventID":"test4","category":"1","name":"Row 7, Seat 11"}},"test3":{"ticket1_1":{"id":"ticket1_1","component":1,"ticketOption":"1","eventID":"test3","count":1,"category":"1","name":"Category 1 (Child)"}}}
|
||||
@@ -1 +0,0 @@
|
||||
{"db":{"libreevent_temp":{},"libreevent_admin":{},"libreevent_orders":{},"libreevent_users":{}},"index":{"libreevent_temp":0,"libreevent_admin":0,"libreevent_orders":0,"libreevent_users":0}}
|
||||
@@ -1 +0,0 @@
|
||||
{"test4":{"name":"Test4Event","description":"Let's see what happens if I update the description, how fast it is reflected in the UI","location":"test2","date":"2023-10-30T10:00:00.000Z","categories":{"1":{"price":{"1":20,"2":30},"bg":"#ff0000","fg":"#ff0000","name":"Category 1","id":"1","ticketCount":1}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"test4","time":"10:00:00.000","startingPrice":20,"currency":"CHF","isDraft":true,"locationName":"TestLocation2","hasSeatplan":true,"totalSeats":353},"test3":{"name":"TestEvent3","description":"This is another test event, this time without seat plan","location":"test","date":"2023-11-25T19:00:00.000Z","categories":{"1":{"price":{"1":20,"2":25},"bg":"#FFFFFF","fg":"#000000","name":"Category 1","id":1,"ticketCount":50},"2":{"price":{"1":30,"2":35},"bg":"#FFFFFF","fg":"#000000","name":"Category 2","id":2,"ticketCount":50}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"test3","time":"19:00:00.000","startingPrice":20,"currency":"CHF","locationName":"TestLocation","hasSeatplan":false,"totalSeats":100},"testStanding":{"name":"Standing Test event","description":"Teststsatahadsf","location":"testLocationNoSeatplan","date":"2023-11-25T10:00:00.000Z","categories":{"1":{"price":{"1":10,"2":15},"bg":"#FFFFFF","fg":"#ff0000","name":"Category 1","id":"1","ticketCount":1}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"testStanding","time":"10:00:00.000","startingPrice":10,"currency":"CHF","locationName":"TestLocationWithoutSeatplan","hasSeatplan":true,"totalSeats":1}}
|
||||
@@ -1 +0,0 @@
|
||||
{"test4":{"name":"Test4Event","description":"Let's see what happens if I update the description, how fast it is reflected in the UI","location":"test2","date":"2023-10-30T10:00:00.000Z","categories":{"1":{"price":{"1":20,"2":30},"bg":"#ff0000","fg":"#ff0000","name":"Category 1","id":"1","ticketCount":1}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"test4","time":"10:00:00.000","startingPrice":20,"currency":"CHF","isDraft":true,"locationName":"TestLocation2","hasSeatplan":true,"totalSeats":353},"test3":{"name":"TestEvent3","description":"This is another test event, this time without seat plan","location":"test","date":"2023-11-25T19:00:00.000Z","categories":{"1":{"price":{"1":20,"2":25},"bg":"#FFFFFF","fg":"#000000","name":"Category 1","id":1,"ticketCount":50},"2":{"price":{"1":30,"2":35},"bg":"#FFFFFF","fg":"#000000","name":"Category 2","id":2,"ticketCount":50}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"test3","time":"19:00:00.000","startingPrice":20,"currency":"CHF","locationName":"TestLocation","hasSeatplan":false,"totalSeats":100},"testStanding":{"name":"Standing Test event","description":"Teststsatahadsf","location":"testLocationNoSeatplan","date":"2023-11-25T10:00:00.000Z","categories":{"1":{"price":{"1":10,"2":15},"bg":"#FFFFFF","fg":"#ff0000","name":"Category 1","id":"1","ticketCount":1}},"ageGroups":{"1":{"id":1,"name":"Child","age":"0 - 15.99"},"2":{"id":2,"name":"Adult"}},"maxTickets":0,"eventID":"testStanding","time":"10:00:00.000","startingPrice":10,"currency":"CHF","locationName":"TestLocationWithoutSeatplan","hasSeatplan":true,"totalSeats":1}}
|
||||
@@ -1 +0,0 @@
|
||||
{"test2":{"locationID":"test2","name":"TestLocation2","seatplan-enabled":true,"totalSeats":352},"test":{"locationID":"test","name":"TestLocation","seatplan-enabled":false},"testLocationNoSeatplan":{"locationID":"testLocationNoSeatplan","name":"TestLocationWithoutSeatplan","seatplan-enabled":true,"totalSeats":0}}
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"pass": "$2b$10$56u70OdMWo/Jv5lrqaNq8OV7TxTDOPGC9tP8Ea.1zhGluHYTzuTd.",
|
||||
"email": "development@janishutz.com"
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
{"test2":{"draft":{"seatInfo":{"data":{"1":{"0":22,"1":22,"2":22,"3":22,"4":22,"5":22,"6":22,"7":22,"8":22,"9":22,"10":22,"11":22,"12":22,"13":22,"14":22,"15":22}},"count":352},"data":{"1":{"x":296.892,"y":13.495,"h":560.66,"w":728.735,"active":false,"draggable":true,"resizable":true,"id":1,"origin":1,"shape":"rectangular","type":"seat","startingRow":1,"seatNumberingPosition":1,"sector":"A","text":{"text":"TestText","textSize":20,"colour":"#20FFFF"},"numberingDirection":"left","category":"1"},"2":{"x":357.007,"y":660.033,"h":117.775,"w":601.145,"active":false,"draggable":true,"resizable":true,"id":2,"origin":3,"shape":"rectangular","type":"stage","startingRow":1,"seatNumberingPosition":1,"sector":"A","text":{"text":"TestText","textSize":20,"colour":"#20FFFF"},"ticketCount":1,"numberingDirection":"left","category":"1"},"3":{"x":517.721,"y":669.847,"h":80.971,"w":304.253,"active":false,"draggable":true,"resizable":true,"id":3,"origin":1,"shape":"rectangular","type":"text","startingRow":1,"seatNumberingPosition":2,"sector":"A","text":{"text":"Stage","textSize":25,"colour":"#2160ff"},"ticketCount":1,"numberingDirection":"left","category":"1"}}},"save":{"seatInfo":{"data":{"1":{"0":22,"1":22,"2":22,"3":22,"4":22,"5":22,"6":22,"7":22,"8":22,"9":22,"10":22,"11":22,"12":22,"13":22,"14":22,"15":22}},"count":0},"data":{"1":{"x":296.892,"y":13.495,"h":560.66,"w":728.735,"active":false,"draggable":true,"resizable":true,"id":1,"origin":1,"shape":"rectangular","type":"seat","startingRow":1,"seatNumberingPosition":1,"sector":"A","text":{"text":"TestText","textSize":20,"colour":"#20FFFF"},"numberingDirection":"left","category":"1"},"2":{"x":357.375,"y":660.049,"h":117.775,"w":601.145,"active":false,"draggable":true,"resizable":true,"id":2,"origin":3,"shape":"rectangular","type":"stage","startingRow":1,"seatNumberingPosition":1,"sector":"A","text":{"text":"TestText","textSize":20,"colour":"#20FFFF"},"ticketCount":1,"numberingDirection":"left","category":"1"},"3":{"x":517.828,"y":670.99,"h":80.971,"w":304.253,"active":false,"draggable":true,"resizable":true,"id":3,"origin":1,"shape":"rectangular","type":"text","startingRow":1,"seatNumberingPosition":2,"sector":"A","text":{"text":"Stage","textSize":25,"colour":"#2160ff"},"ticketCount":1,"numberingDirection":"left","category":"1"}}}},"test":{"draft":{},"save":{"seatInfo":{"data":{"1":{"0":22}},"count":0},"data":{"1":{"x":427.696,"y":160.539,"h":371.324,"w":734.069,"active":false,"draggable":true,"resizable":true,"id":1,"origin":1,"shape":"rectangular","type":"stand","startingRow":1,"seatNumberingPosition":1,"sector":"A","text":{"text":"TestText","textSize":20,"colour":"#20FFFF"},"numberingDirection":"left","category":"1","ticketCount":50}}}},"testLocationNoSeatplan":{"draft":{},"save":{"seatInfo":{"data":{"1":{"0":9,"1":9,"2":9,"startingRow":1}},"count":0},"data":{"1":{"x":375,"y":169.118,"h":294.118,"w":750,"active":false,"draggable":true,"resizable":true,"id":1,"origin":1,"shape":"rectangular","type":"stand","startingRow":1,"seatNumberingPosition":1,"sector":"A","text":{"text":"TestText","textSize":20,"colour":"#20FFFF"},"numberingDirection":"left","category":"1","ticketCount":50}}}}}
|
||||
File diff suppressed because one or more lines are too long
@@ -105,7 +105,7 @@ module.exports.checkDataAvailability = ( db, column, searchQuery ) => {
|
||||
|
||||
module.exports.getJSONData = ( file ) => {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
fs.readFile( path.join( __dirname + '/data/' + file + '.json' ), ( error, data ) => {
|
||||
fs.readFile( path.join( __dirname + '/../../data/' + file + '.json' ), ( error, data ) => {
|
||||
if ( error ) {
|
||||
reject( 'Error occurred: Error trace: ' + error );
|
||||
} else {
|
||||
@@ -121,7 +121,7 @@ module.exports.getJSONData = ( file ) => {
|
||||
|
||||
module.exports.getJSONDataSimple = ( file, identifier ) => {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
fs.readFile( path.join( __dirname + '/data/' + file + '.json' ), ( error, data ) => {
|
||||
fs.readFile( path.join( __dirname + '/../../data/' + file + '.json' ), ( error, data ) => {
|
||||
if ( error ) {
|
||||
reject( 'Error occurred: Error trace: ' + error );
|
||||
} else {
|
||||
@@ -141,7 +141,7 @@ module.exports.getJSONDataSync = ( file ) => {
|
||||
|
||||
module.exports.writeJSONDataSimple = ( db, identifier, values ) => {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
fs.readFile( path.join( __dirname + '/data/' + db + '.json' ), ( error, data ) => {
|
||||
fs.readFile( path.join( __dirname + '/../../data/' + db + '.json' ), ( error, data ) => {
|
||||
if ( error ) {
|
||||
reject( 'Error occurred: Error trace: ' + error );
|
||||
} else {
|
||||
@@ -150,7 +150,7 @@ module.exports.writeJSONDataSimple = ( db, identifier, values ) => {
|
||||
dat = JSON.parse( data ) ?? {};
|
||||
}
|
||||
dat[ identifier ] = values;
|
||||
fs.writeFile( path.join( __dirname + '/data/' + db + '.json' ), JSON.stringify( dat ), ( error ) => {
|
||||
fs.writeFile( path.join( __dirname + '/../../data/' + db + '.json' ), JSON.stringify( dat ), ( error ) => {
|
||||
if ( error ) {
|
||||
reject( 'Error occurred: Error trace: ' + error );
|
||||
}
|
||||
@@ -163,7 +163,7 @@ module.exports.writeJSONDataSimple = ( db, identifier, values ) => {
|
||||
|
||||
module.exports.writeJSONData = ( db, data ) => {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
fs.writeFile( path.join( __dirname + '/data/' + db + '.json' ), JSON.stringify( data ), ( error ) => {
|
||||
fs.writeFile( path.join( __dirname + '/../../data/' + db + '.json' ), JSON.stringify( data ), ( error ) => {
|
||||
if ( error ) {
|
||||
reject( 'Error occurred: Error trace: ' + error );
|
||||
} else {
|
||||
@@ -175,7 +175,7 @@ module.exports.writeJSONData = ( db, data ) => {
|
||||
|
||||
module.exports.deleteJSONDataSimple = ( db, identifier ) => {
|
||||
return new Promise( ( resolve, reject ) => {
|
||||
fs.readFile( path.join( __dirname + '/data/' + db + '.json' ), ( error, data ) => {
|
||||
fs.readFile( path.join( __dirname + '/../../data/' + db + '.json' ), ( error, data ) => {
|
||||
if ( error ) {
|
||||
reject( 'Error occurred: Error trace: ' + error );
|
||||
} else {
|
||||
@@ -184,7 +184,7 @@ module.exports.deleteJSONDataSimple = ( db, identifier ) => {
|
||||
dat = JSON.parse( data ) ?? {};
|
||||
}
|
||||
delete dat[ identifier ];
|
||||
fs.writeFile( path.join( __dirname + '/data/' + db + '.json' ), JSON.stringify( dat ), ( error ) => {
|
||||
fs.writeFile( path.join( __dirname + '/../../data/' + db + '.json' ), JSON.stringify( dat ), ( error ) => {
|
||||
if ( error ) {
|
||||
reject( 'Error occurred: Error trace: ' + error );
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* libreevent - jsonDataHelper.js
|
||||
*
|
||||
* Created by Janis Hutz 07/16/2023, Licensed under the GPL V3 License
|
||||
* https://janishutz.com, development@janishutz.com
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
// IMPORTANT: Do not use this helper in any other context than in the jsondb.js file!
|
||||
// It is specifically designed for that thing and therefore doesn't use any unnecessary resources!
|
||||
|
||||
|
||||
class DataHelper {
|
||||
constructor () {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = DataHelper;
|
||||
@@ -21,7 +21,7 @@ class JSONDB {
|
||||
connect () {
|
||||
let data = {};
|
||||
try {
|
||||
JSON.parse( fs.readFileSync( path.join( __dirname + '/data/db.json' ) ) );
|
||||
JSON.parse( fs.readFileSync( path.join( __dirname + '/../../data/db.json' ) ) );
|
||||
} catch ( err ) {
|
||||
console.error( '[ JSON-DB ] CRITICAL INITIALIZATION FAILURE!' + err );
|
||||
throw ( 'JSONDB failed to start!' );
|
||||
@@ -44,7 +44,7 @@ class JSONDB {
|
||||
}
|
||||
|
||||
save () {
|
||||
fs.writeFile( path.join( __dirname + '/data/db.json' ), JSON.stringify( { 'db': this.db, 'index': this.dbIndex } ), ( err ) => {
|
||||
fs.writeFile( path.join( __dirname + '/../../data/db.json' ), JSON.stringify( { 'db': this.db, 'index': this.dbIndex } ), ( err ) => {
|
||||
if ( err ) console.error( '[ JSON-DB ] An error occurred during saving: ' + err );
|
||||
this.isSaving = false;
|
||||
if ( this.awaitingSaving ) {
|
||||
@@ -56,13 +56,13 @@ class JSONDB {
|
||||
async resetDB () {
|
||||
this.db = { 'libreevent_temp': {}, 'libreevent_admin': {}, 'libreevent_orders': {}, 'libreevent_users': {} };
|
||||
this.dbIndex = { 'libreevent_temp': 0, 'libreevent_admin': 0, 'libreevent_orders': 0, 'libreevent_users': 0 };
|
||||
fs.writeFile( path.join( __dirname + '/data/db.json' ), JSON.stringify( { 'db': this.db, 'index': this.dbIndex } ) );
|
||||
fs.writeFile( path.join( __dirname + '/../../data/db.json' ), JSON.stringify( { 'db': this.db, 'index': this.dbIndex } ) );
|
||||
}
|
||||
|
||||
async setupDB () {
|
||||
this.db = { 'libreevent_temp': {}, 'libreevent_admin': {}, 'libreevent_orders': {}, 'libreevent_users': {} };
|
||||
this.dbIndex = { 'libreevent_temp': 0, 'libreevent_admin': 0, 'libreevent_orders': 0, 'libreevent_users': 0 };
|
||||
fs.writeFile( path.join( __dirname + '/data/db.json' ), JSON.stringify( { 'db': this.db, 'index': this.dbIndex } ) );
|
||||
fs.writeFile( path.join( __dirname + '/../../data/db.json' ), JSON.stringify( { 'db': this.db, 'index': this.dbIndex } ) );
|
||||
}
|
||||
|
||||
query ( operation, table ) {
|
||||
|
||||
Reference in New Issue
Block a user