Sharing memory-only NeDB instance in multiple Electron BrowserWindows - node.js

We are developing an app using Electron and Vue.js. In our app we are using NeDB for temporarily storing JSON documents after having received (and decrypted) them from a Firebase Database. A requirement of the app is, that the decrypted data stays in memory and is not saved to disk during the user session. Therefore we use NeDB with the inMemoryOnly flag.
Our goal is to show reports for contents of the database in a different BrowserWindow to print / save them as PDF.
We tried to initialize the database using a global variable, but unfortunately the database content was empty. Is there another possibility to access the database from within a different BrowserWindow?

Related

How to initialize Variables from Database and use them Globally in ExpressJs

I am building an API with NodeJs (expressJs).
I would be accessing 3rd party Services at several points using API Keys stored in my database(MySQL).
I was wondering if there was a way to initialize all the required API Keys from the database and save them as variables in a .Js file as soon as the server starts. Then require these files wherever the variables are needed.
I do not want to store the API KEYS plainly in any .js or .env file, but I want them to be found only in database, initialized at start of the program and then available everywhere.

Where is the data stored in localhost?

i followed a tutorial and made a todo list web app using nodejs, express and ejs. after completing i used ngrok to make my localhost public so that i can share it with my friends, now i've realized that the tasks that i add on my todo list are saved in my server unless i restart it or close it completely. i want to know where the tasks which is a is stored in my local machine, does nodejs store it, or its saved in the memory of my local machine, more importantly if its already being stored somewhere why do i have to worry about using a database server like mongodb or firebase? hope my question is clear.
If you store your data in array or something in your code i can say "Yes. the data would be stored in the memory of your local machine".
And you don't have to worry about database if you don't have to permanently store your data.

Creating an Express API from MongoDB server automatically

I have a pretty large MongoDB server running on my local machine, I know how to create an API using Express & Node.js and know how to use routes, etc. But I only know how to add new data to a route using the POST method. My database has tens of thousands of entries in different collections and so it would be impossible to add them all manually.
I wanted to know if there was a way to quickly convert my entire mongodb local database into an API with Express so I can access it client-side from my React.js application.

Storing images in MongoDB locally via script/json

I am building a project using the MEVN stack. The website is a game seller web, and when I had to store the images in the Mongo database, I realised that it was a little bit more difficult than I thought. I finally used multer to store the images but I am only able to store them using POSTMAN and its file upload functionality. My problem is the customer wants a local demo with already stored data in the database, without using any external program. I've worked with Mongo and I know it is possible to charge the DB data using a JSON file or even a JSON variable into the DB script, but I don't know if it is possible to include the image 'originalName' from a image already stored in the /uploads folder.
This is my game model:
MongoDB game model
Here is the DB object and the way the image is stored (Then I use the originalName to get it via relative paths):
MongoDB Compass DB object
And finally here is my post method (Currently I'm using POSTMAN to populate the data and it is tedious):
POST game method
Please I need a way to store this 'image name' into my DB at the beginning of the first compilation of the project. I don't even know if I have to store the images first and then export the project with this base images to populate the database, or there is an easier way to do it. Thank you very much!

Export Nedb contents

I have an electron app that acts as a tool to speed up game development. When a user opens the app they can begin importing assets and setting custom properties. I store these properties in nedb. The way I have my application set up, every page change the properties from nedb are fetched and are immediately reflected on the page. I need to save these changes in a file the app can load and it would be intuitive to use nedb since it loads database info from a file optionally out of the box. However in the instance a user opens my app and begins working without a file, I have no way to store these changes for later use. I have found no docs for exporting the database on the fly.

Resources