hey guys,
i am using firebase for backend sevices , but my app need to be work offline , my is a directory (sell & buy apps) i need the data to be available to work offline and online , what the kind of database should i use (sqllite,PouchDB & CouchDB) ?
and i need an example to use what you choose with firebase .
Thank You
any solution to my problem?
CouchDB is a database system like firebase… so you would use PouchDB with firebase.
If you want some predefined structure for syncing the databases i would choose PouchDB.
If you do not have any requirements for paging/searching (using real database features) you can simply use sqlite.
A table would have then two columns --> value (JSON-string) and an indicator for syncing like a timestamp.
thank you bengtler,
i don`t have idea about the code should be between firebase and sqllite , can you give me an example of how to sync data between firebase and sqllite ?
Hi, below an example of how to do it:
firebase.database().ref('/users/user1/recent').on('value', (snapshot) => {
let db = new PouchDB('dbname');
db.put(snapshot.val());
});
In the first line you’re getting the values from FB, after that you simply store the data with PouchDB.
yeah, so you have to implement the syncing methods on your own --> what data need to be saved and sooooo on.
thank you , but i have question :
is pouchdb store data like firebase, i mean if it have childs like firebase , if i have a sell and buy app , the root node is ‘cats’, and it has a child nodes like ‘mobiles’ , ‘pcs’,‘laptops’ ,… etc ,can i store this structure in pouchdb , or make a new database for every cat in the app ?