0

All the example cloudant query selectors in that documentation and that I can find have known field names, e.g:

{
  "selector": {
       "name": "John"
  },
  ......
}

I've got a document that's a collection of objects named with the user's email address, like so:

{
   "_id":  "nnnnnn",
   "_rev": "nnnnnnn",
   "bill@anon.com": {
       "name": "William Smith",
       "age":  25
   },
   "jane@gmail.com" {
       "name": "Jane Doe",
       "age":  27
   }
   ....
}

I want to do a selector that wildcards the object name so that it's functionally equivalent to

{
  "selector": {
       "*.age": { "$gt": 21 }
  },
  ......
}

any ideas on how to achieve this?

mnsuk
  • 39
  • 3
  • 1
    You could accomplish this with a traditional CouchDB view. I don't think the Mango queries will support it, though. – Jonathan Hall Sep 28 '17 at 16:18
  • Are you willing to frob your data model such that those people are contained by an array? Something like this: {"_id":"nnn", "_rev":"nnn", "people":[ { "email":"jane@gmail.com", "name":"Jane Doe" }, { "email":"bill@anon.com", "name":"William Smith" } ] } If so, guidance is here: https://stackoverflow.com/questions/43709358/cloudant-mango-selector-for-deeply-nested-jsons – bradnoble Sep 28 '17 at 19:20

0 Answers0