0

I am developing an admin panel where I can add biological species data and their characteristic. The problem here is I have different selected users which have to enter data but some of the users don't have internet connectivity so either I have build localhost for the users with no internet connection where they can store data and when they get an internet connection the data should automatically get synced with the web server where we have main MongoDB database. I can do it this we but I don't know how can I do this?.... If this is soo complicated I can export the database from the localhost server and then upload it to the main server individually.

If we go in either of the ways, the issue is we have to overwrite the data which is already present also we have to update the database in the main server after the users update the data on a localhost server. How can I make this consistent?

I need to know two answers to the above scenario

1) Is it possible to build an offline MongoDB based system which will get synced with the online server after getting an internet connection? implicitly or explicitly whichever is possible

2) How can we make the database properly working when the multiple CSV files we upload should not make the database scrambled.

I would like to have as many answers as I can so that I can learn to make my admin panel as close to perfect.

  • Possible duplicate of [How to use mongoimport to import csv](https://stackoverflow.com/questions/4686500/how-to-use-mongoimport-to-import-csv) – Book Of Zeus May 27 '18 at 00:53

1 Answers1

0

The answer here is not technical one but you can do this way. For the systems with no internet connection, prepare the JSON data on their local machine. Add a PUSH button i.e when client local machine is connected to the internet they can press PUSH button which will push all the JSON data prepared on client local system to Sever.

Now on server side prepare an endpoint that should take JSONString as input and then you can identify which data to store in which collection and save the data to your database.

Another way you can convert this JSON to CSV format and then have a service that runs synchronously in the background which will upload the CSV data in the database.

Last but most important if you are lazier in doing all the stuff above then you can use Couchbase Lite.

This is not the best answer but probably this will work for you.

HTH Thanks!

Lalit Dashora
  • 467
  • 5
  • 16
  • Thanks a lot for your reply. I will research and use this approach. – saurabh jaiswal May 25 '18 at 07:32
  • Can you tell me one other thing? For example, if we have 3 documents. let us consider that in 1 document we have 2 phone numbers in a phone number field. If in an offline database i.e. JSON data we have updated one phone number and also we have added one phone number. so out of three phone numbers, we have 1 updated and another one is new. How will the main server database accept these two changes? .... I would like to know the mechanism of this. The document id can be different compared to server's id. – saurabh jaiswal May 25 '18 at 07:42
  • A better answer is don't have a headache in making all these endpoints. Just explore Couchbase Lite, this will help you directly syncing the local db with the server. I have added the link of Couchbase lite above in the answer. – Lalit Dashora May 26 '18 at 05:20