如何处理离线时使用本地 mongodb 数据库并在线时同步到远程 mongodb 服务器的流星应用程序?
How to handle a meteor app that uses local mongodb database when offline and syncs to remote mongodb server when online?
我需要帮助来解决我目前在开发应用程序时面临的挑战。
该应用程序是使用 meteor 制作的,并且有一个使用 meteor-desktop 制作的桌面版本。如果安装该应用程序的 PC 处于在线状态,则一切正常,但我们要求离线版本正常工作(就像即使处于离线状态,您仍然可以在 Microsoft Outlook 中访问电子邮件一样)。
理想的场景是当 PC 连接到互联网时,流星应用程序使用远程 mongodb 服务器,然后切换到使用安装在 PC 中的本地 mongodb当它离线时。那么在远程服务器上线时,存储在本地数据库中的数据应该全部同步到远程服务器中的数据库中,反之亦然。
如有任何建议,我们将不胜感激。谢谢
Meteor 中离线支持的最简单解决方案是frozeman:persistent-minimongo2
which is an Atmosphere.js package. It will store your objects in localstorage. Notice there is a storage limitation up to 4.8MB for persistent-minimongo2
. Another option which is more commonly used for offline support across Meteor's community is ground:db
It is a bit more complex to use compared to frozeman:persistent-minimongo2
but it provides better flexibility. There are also more resources in Internet about ground:db
. For example, you can refer to the Meteor's Forum page。
我需要帮助来解决我目前在开发应用程序时面临的挑战。
该应用程序是使用 meteor 制作的,并且有一个使用 meteor-desktop 制作的桌面版本。如果安装该应用程序的 PC 处于在线状态,则一切正常,但我们要求离线版本正常工作(就像即使处于离线状态,您仍然可以在 Microsoft Outlook 中访问电子邮件一样)。
理想的场景是当 PC 连接到互联网时,流星应用程序使用远程 mongodb 服务器,然后切换到使用安装在 PC 中的本地 mongodb当它离线时。那么在远程服务器上线时,存储在本地数据库中的数据应该全部同步到远程服务器中的数据库中,反之亦然。
如有任何建议,我们将不胜感激。谢谢
Meteor 中离线支持的最简单解决方案是frozeman:persistent-minimongo2
which is an Atmosphere.js package. It will store your objects in localstorage. Notice there is a storage limitation up to 4.8MB for persistent-minimongo2
. Another option which is more commonly used for offline support across Meteor's community is ground:db
It is a bit more complex to use compared to frozeman:persistent-minimongo2
but it provides better flexibility. There are also more resources in Internet about ground:db
. For example, you can refer to the Meteor's Forum page。