dongyan7876 2018-05-25 05:15
浏览 657

我们如何将csv文件主动导入mongodb?

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.

  • 写回答

1条回答

  • douwen5066 2018-05-25 06:11
    关注

    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!

    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站