title: Is it possible to use Realm object server real time sync without indices?
body: <p>I was looking into real time sync as implemented in Realm's "tasks" example app.</p>
  
  <p>In particular, this block:</p>
  
  <pre><code>private func setupNotifications() -&gt; NotificationToken {
      return parent.items.addNotificationBlock { [unowned self] changes in
          switch changes {
          case .Initial:
              // Results are now populated and can be accessed without blocking the UI
              self.viewController.didUpdateList(reload: true)
          case .Update(_, let deletions, let insertions, let modifications):
              // Query results have changed, so apply them to the UITableView
              self.viewController.tableView.beginUpdates()
              self.viewController.tableView.insertRowsAtIndexPaths(insertions.map { NSIndexPath(forRow: $0, inSection: 0) }, withRowAnimation: .Automatic)
              self.viewController.tableView.deleteRowsAtIndexPaths(deletions.map { NSIndexPath(forRow: $0, inSection: 0) }, withRowAnimation: .Automatic)
              self.viewController.tableView.reloadRowsAtIndexPaths(modifications.map { NSIndexPath(forRow: $0, inSection: 0) }, withRowAnimation: .None)
              self.viewController.tableView.endUpdates()
              self.viewController.didUpdateList(reload: false)
          case .Error(let error):
              // An error occurred while opening the Realm file on the background worker thread
              fatalError(String(error))
          }
      }
  }
  </code></pre>
  
  <p>Basically the changes are communicated using indices. By simply accessing the underlaying model / realm object using these indices the interface is updated.</p>
  
  <p>Now I have an architecture that doesn't seem compatible with this. I have a dedicated database layer (of which realm is an implementation), where I load the realm objects in a background thread and map to plain model objects. This way I decouple my code from the database implementation and can use immutable models.</p>
  
  <p>I'm not sure how to handle the indices in this case. Looks like I should remember the original query, do it again, and then access the entries I need using these indices? That sounds very inefficient... </p>
  
  <p>Additionally, I don't know how the indices work with specific queries like "all items that have status x in field y" - does the index I receive refers to this specific query?</p>
  
  <p>What is the recommended way to proceed here?</p>
  
  <p>Edit: Just to add some additional commentary, I implemented myself sync functionality using a custom server and websockets, and I used semantic keys instead of indices (sometimes I even sent the complete object to avoid having to query the database). This way I had not to deal with possible inconsistencies resulting of index based access. Wonder if something like that is possible or planed with Realm sync at some point.</p>
  
  <p>P.S. I intend to switch to Realm sync because my custom server is not well tested and very hard to maintain. I hope that this is possible.</p>