简体   繁体   English

通过领域框架如何快速与Web服务器同步(更新和下载)?

[英]By realm framework how to sync (update & download) with webserver in swift?

I want to take value from local realm database and save it to realm object-server database and then (after user login) I want to fetch data value from realm object-server database . 我想从本地领域数据库中获取价值并将其保存到领域对象服务器数据库中 ,然后(在用户登录后)我想从领域对象服务器数据库中获取数据值。 How can I do this? 我怎样才能做到这一点? Can I achieve my sync (between realm Local database and realm object-server) feature by only Realm without additional web API ? 我可以通过Realm来实现我的同步(在Realm本地数据库和Realm对象服务器之间)功能,而无需其他Web API吗?

Additionally: 另外:

try! self.realm.write
  {
    self.realm.add(task)
  } 

I observed, the above code add the task object to local database. 我观察到,以上代码 任务对象添加到本地数据库。 But not add this task object to web object server database? 但是不将此任务对象添加到Web对象服务器数据库中吗? So, my key question is How can save this task object to remote web object server " by Realm? 因此,我的关键问题是Realm如何将该任务对象保存到远程Web对象服务器

If you open your self.realm as a synced Realm, the local copy of the Realm and the copy of the Realm on the server will automatically stay in sync with each other. 如果将self.realm作为同步的Realm打开,则Realm的本地副本和服务器上Realm的副本将自动保持彼此同步。 You don't need to write any additional calls to web APIs. 您无需编写对Web API的任何其他调用。

To configure a Realm to sync to a server, you need to set the syncConfiguration property on its configuration object. 要将领域配置为同步到服务器,您需要在其配置对象上设置syncConfiguration属性。 Please refer to our documentation on synced Realms for more information about how to use this feature. 请参阅有关同步领域文档,以获取有关如何使用此功能的更多信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM