Search code examples
swiftcouchbasecouchbase-lite

Can i query the database in the middle of a 'map' closure with Couchbase Lite?


In Couchbase Lite, is this permissible/encouraged or will it cause race conditions / any other problems?

let view = database.viewNamed("myView")
view.setMapBlock({ properties, emit in
  database.existingDocument(withID: properties["some_foreign_key"])

Basically i'm trying to create a view which is the equivalent of an SQL 'left inner join'.


Solution

  • It is not permitted. Map functions must be pure, as in given the same set of inputs they will always produce the same outputs. No external state may be referenced.