Few months ago I got a customer who wanted me to develop management system for his local business. He wanted it to be a desktop App with local data storage. I chose to use my favorite electronJS as a framework for this Desktop app but I faced the challenge on how I would implement database on it.
I tried to use mysql drivers on nodeJS but that option didn't provide required portability(It needed database server). So I began a search and I came across this library called LOVEFIELD Made and supported by Google.
Lovefield is a relational database that uses indexedDB on browsers to store data for websites. Since electron framework just provides a chromium-like browser for your app to run, lovefield becomes a cheap and portable solution to implement relational database support for your app.
CONFIGURING LOVEFIELD IN ELECTRONJS PROJECT
Here we go.. Start by going to the root of your electronJS project and install lovefield using npm's
npm install --save lovefield
. After it has been downloaded the next part is loading it to your project
So to go around this you have to use the normal browser-like way in your
index.html file (or any other
html file where lovefield will be used), I mean you should use the
<script> tag to load
lovefield. You can load it like this
After loading it you can use the
lf namespace to access all lovefield APIs and Classes.
Thanks for reading to this far, this is part one of my article on
lovefield. The next part will focus more on how to use
lovefield, most common errors and what precautions you should always take when using
lovefield as your relational database.