将MongoDB服务器数据同步到IndexedDB本地存储 [英] Synchronizing MongoDB server data to an IndexedDB local store

查看:422
本文介绍了将MongoDB服务器数据同步到IndexedDB本地存储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用IndexedDB来评估解决离线问题。它将填充当前存储在MongoDB数据库中的数据(按原样)。

I'm trying to evaluate using IndexedDB to solve the offline issue. It would be populated with data currently stored in a MongoDB database (as is).

一旦数据存储在IndexedDB中,它可能会在MongoDB服务器上更改,我需要传播这些变化。是否有任何现有的框架或库可以像Mongo 那样。我已经了解CouchDB / PouchDB并且我没有探索这两个。

Once data is stored in IndexedDB, it may be changed on the MongoDB server and I need to propagate those changes. Is there any existing framework or Library to do somehting like this for Mongo. I already know about CouchDB/PouchDB and am not exploring those two.

推荐答案

我没有使用过IndexDB,但设计问题并不少见。我对您的应用程序的理解是,当客户端连接到MongoDB时,您将一组文档拉下来进行本地存储并断开连接。然后客户端可以在本地执行操作(不连接到数据服务器),然后推送更改。

I haven't worked with IndexDB, but the design problem isn't that uncommon. My understanding of your app is that when the client makes the connection to MongoDB, you pull a set of documents down for local storage and disconnect. The client then can do things locally (not connected to the data server), and then push up the changes.

我看到它的方式你必须处理两个一般情况:

The way I see it you've got to handle two general cases:


  1. 当MongoDB服务器更新并打破与客户端的连续性时,客户端将需要

  1. when the MongoDB server is updated and breaks continuity with the client, the client will have to

  1. 对数据进行轮询(计时器?)或

  2. 保持websocket打开,让通知在管道上自由流动


  • 当用户需要将更改的数据推回管道时

  • when the user needs to push changed data back up the pipe


    1. 你可以重新连接异步,检查状态更改,(根据业务规则解决冲突)

    2. 有一个服务器端(轻量级)接口,用于处理冲突(取决于应用程序的复杂性,比较时间戳) MongoDB状态更改为IndexedDB更新应该足够了)


  • 这篇关于将MongoDB服务器数据同步到IndexedDB本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆