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!

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘