I have been developing an app using Couchbase Server, Sync Gateway and iOS SDK and having been through the documentation several times am still confused as to the best way to tackle a particular use case so I really would appreciate some feedback to get some clarity.
I have a document of type 'object' which may be owned by a 'user' document via an 'owned_by' property on the 'object' document. All 'object' documents also have a 'latitude' and 'longitude' property and a 'source_ref' property that references another document of type 'source'. In iOS I am querying 'object' documents using 2 different views and then setting them up as live queries that run in the background. The first view map function queries all documents where the 'owned_by' property contains the current users email and the second uses the boundingbox function to get all documents within close proximity to the user via their 'latitude' and 'longitude' properties. The properties are constantly changing and thus the live query will potentially be returning new 'object' documents several times a minute. This all works fine but the issue I am having is that every time the app pulls all the document of type 'object' using these live query views, I need to then use their 'source_ref' property to go and pull a very small subset of 'source' documents specifically by their IDs from the server. Up to now I have just been pulling all the 'source' documents so I have them to hand when I need them but there could over time potentially be tens of thousands of documents of type 'source' and I am only interested in pulling a very small subset by their ID every time the live queries return results. It is my understanding that I can't create a dynamic condition for a view (i.e. the 'source_ref' properties of the 'object' documents as they are returned by a live query) so is there a simple way I am missing that this can be achieved using views map reduce function or can I simply create an array of the document ID's I want to pull from the server to my local db and query them one by one in the background? I've looked at the documentation on simulating relationships but this seems a very SQL approach and maybe not the best way to achieve want I want to do. Any advice on how you would approach this would be much appreciated. Toby -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/56909e25-2235-4e1c-8db5-8a83b8163374%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
