CouchDB: Accessing Nested Structures in Map Functions
I have a document based on an xml structure that I have saved in a CouchDB database.
Some of the keys contain namespaces and are in the form "namespace: key":
{"mykey": {"nested:key": "nested value"}}
In the map function, I want to highlight the nested value as a key, but the colon inside the name makes it difficult ...
emit(doc.mykey.nested:key, doc) <-- will not work.
Does anyone know how this can be solved?
a source to share
This is because Couch is a JSON based document DB and doc.mykey.nested: key is not a valid JSON identifier. JSON IDs must match JavaScripts IDs and: is not a valid ID character.
So the simple answer is "No, it won't and can't work." You need to change your IDs.
Actually, I must qualify this.
The couch can use almost EVERYTHING for it by views et al, and theoretically works with any payload. But out of the box, it's just JavaScript and JSON.
a source to share