将 mongodb 数据库与本地序列化版本同步的最佳方法

发布于 2024-10-08 00:10:19 字数 498 浏览 2 评论 0原文

我正在开发一个 Mac 应用程序,使用 Objective-C 和本机工具。我喜欢 mongodb 基于文档的实现,我计划使用它来存储我的应用程序的数据(数据或多或少是音乐曲目的标题及其随附的元数据)。该应用程序的目的是允许用户能够将数据库的数据库版本同步到其本地版本。然后,能够始终在计算机上拥有本地版本,因此不需要互联网即可使用该应用程序。但是,如果用户离线并对其本地数据进行了更改,当他们重新上线时,更改将同步回 mongodb 数据库。我遇到的问题是找到解决这个问题的最佳方法。我现在能想到的最好的方法是首先从数据库中提取数据并序列化数据库中每个“音乐曲目”条目的本地副本。因此,当离线时,问题将从这些序列化对象填充数据。如果用户离线添加/更改数据,这些更改将被记录下来,并等待用户重新上线时推送到 mongodb 数据库。 mongodb 数据库中的所有条目都会带有时间戳,因此当应用程序在线运行时,每隔几秒,应用程序就可以比较本地副本和远程副本的时间戳,以查看是否已进行更改,并进行相应更新。

这是从 mongodb 数据库远程和本地同步数据的好方法吗?

I am developing a mac application, using objective-c and the native tools. I love mongodb's document based implementation and I plan to use it to store the data for my application (the data will more or less be the title of music track, with its accompanying metadata). The aim of the application is to allow users to be able to sync up the database version of the database, to their local version. And then, be able to always have a local version on their computer, so the internet wouldn't be needed to use the application. But if the user was offline, and made changes to their local data, when they get back online the changes would be synced back up to the mongodb database. The problem I'm having is finding the best approach to this problem. The best I can think of right now, is to initially pull the data from the database and serialize local copies of each "music track" entry in the database. So when offline, the problem would populate data from these serialized objects. If the user added/changed data offline, the changes would be noted, and would wait to be pushed to the mongodb database when the user got back online. All entries in the mongodb database would be timestamped, so when the application was running online, every few seconds, the application could compare timestamps from its local copy and remote copy to see if changes have been made, and update accordingly.

Is this a good approach to syncing up data remotely and locally from a mongodb database?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸印温柔 2024-10-15 00:10:19

这是一个非常有趣的问题,遗憾的是我没有一个很好的答案(目前其他人似乎也没有这样做。)

但是,您可能对 MongoSV 最近关于在 iOS 中使用 MongoDB 的演示感兴趣 ...

http://www.10gen.com/video/mongosv2010/ios< /a>

在演讲中 Tim Burks 提到了他正在从事的一些在 iOS 设备上存储 MongoDB 数据的项目,这可能对你有一些帮助。

例如,他提到 Tokyo Cabinet ...理论上你可以在 SQLite 中存储 BSON/JSON 结构(有点奇怪,但可行。)

This is a very interesting question and sadly I don't have a great answer for it (nor does it seem others do at this point.)

However, you might be interested in this recent presentation from MongoSV on Using MongoDB With iOS ...

http://www.10gen.com/video/mongosv2010/ios

In the presentaion Tim Burks mentions some projects he's working on for storing MongoDB data on iOS devices, it might be some help to you.

He mentions Tokyo Cabinet for example ... you could in theory store BSON/JSON structure in SQLite (a little weird, but doable.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文