Interesting — so you have sort of a build-your-own-database app, where users can define their own fields and then populate records with them?
The JSON you showed looks reasonable, although it’ll help performance if you can avoid using UUIDs for the field identifiers. The shorter the better. Have you considered making the field identifier be the user-visible name of the field, perhaps with a prefix added to disambiguate it from the built-in fields like “sortOrder”? The only drawback would be that if you allow these fields to be renamed, it would require updating every document containing that field. > I also need to be able to query by any of the fields in the database in a > variety of ways. For example, date ranges, numeric ranges, full text queries, > empty values, not empty values, possibly all combined. Couchbase Lite isn’t super good at this. It’s easy to do in SQL because you can piece together a SELECT statement at runtime and the database will evaluate it, and even if the data isn’t indexed for that query it’ll do its best by linear searching. It also knows how to combine results from multiple indexes. Couchbase Lite’s map/reduce system requires that you have an index for what you want to search on, and if you need to merge results from multiple indexes you have to do it by hand. We’d like to improve this in the future (possibly by adopting the N1QL query language) but that doesn’t help you now. Take a look at the new CBLQueryBuilder <https://github.com/couchbase/couchbase-lite-ios/wiki/Query-Builder> class available in 1.1 for iOS/Mac. It’s similar to Core Data’s NSFetchRequest: it lets you define a query using NSPredicate, NSExpression and NSSortDescriptor. Behind the scenes it will create a view to generate the necessary index. If you’re using this for ad-hoc queries, it may end up creating a lot of views, which can reduce performance, so you may want to manually delete them from time to time. —Jens -- 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 mobile-couchbase+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/8BB82267-70AF-4496-A222-2807CD15E365%40couchbase.com. For more options, visit https://groups.google.com/d/optout.