Hi, I am working on Ionic 3 and saving this Api’s data onto my local SQL, (SQlite) but i want to save the api’s data with identical structure. Please help.
Api:
http://api.alquran.cloud/quran/ar.alafasy
Example:
Hi, I am working on Ionic 3 and saving this Api’s data onto my local SQL, (SQlite) but i want to save the api’s data with identical structure. Please help.
Api:
http://api.alquran.cloud/quran/ar.alafasy
Example:
Try this in the SQL lite ionic native transactions methods (I don’t know the name of the methods. They are called transactions or query.)
SQL transactions:
create table surahs ( number smallint, name varchar(100), englishname varchar(100), englishnametranslation varchar(100), revelationtype varchar(100) );
create table ayahs ( FOREIGN KEY(surahs_number) references surahs (number), audio varchar(100), text varchar(100), numberissurah smallint, juz varchar(100), manzil smallint, page smallint, ruku smallint, hizbquarter smallint, sajda boolean);
insert into surah values ( ${surahs[i].number}, ${ surahs[i].name}, ${ surahs[i].englishname }, ${ surahs[i].englishnametranslation }, ${ surahs[i].revelationtype });
insert into ayahs ${ surahs[i].ayahs[i].surahs_number},${ surahs[i].ayahs[i].audio },${ surahs[i].ayahs[i].text },${ surahs[i].ayahs[i].numberissurah },${ surahs[i].ayahs[i].juz },${ surahs[i].ayahs[i].manzil },${ surahs[i].ayahs[i].page },${ surahs[i].ayahs[i].ruku },${ surahs[i].ayahs[i].hizbquarter },${ surahs[i].ayahs[i].sajda });
*where the number in ayahs should be the same as in surahs
*surahs_number in table ayahs should be the same as number in surahs table, if not it will fail.
*check the datatypes since I don’t use SQL lite much and it may differ, I used the one I see a lot in DB and are considered universal.
*the variable i is a number. It can be anything you want. I wrote it as if it was going through a for loop.
*if you want to save it as an object/JSON (exactly as you show in your pic) you could check out LokiJS, a NOSQL database. I use in my project and it does wonders.