What sort of statements can I use in Couchbase?
I'm trying to add some processing to the Map function in Couchbase view, but not sure what syntax or language I can use there. The documentation only explains about "emit" and switch/case statements.
What I'm trying to do specifically is save different records to different files on the operating system depending on their id. This is to be done inside map function.
Could you please let me know how to do that or if you have a reference to more detailed specifications of the language to use inside Map function.
A view in Couchbase is using Map and Reduce only to create index, what I mean by this is:
- each document saved/updated are sent to the map function and reduce
- then you emit(K,V) that will save this in the "Couchbase" index file (also with the ID of the document)
This file is used to Query the database, to get the id of document or aggregates.
Couchbase Map/Reduce should not be views a "data process/triggers" but only as Indexer, to create what I like to call a materialized view. So you cannot use the Map function to create your own file or call other resources. Only use it to index documents (and you can use any JS you want).
May be this chapter in the documentation could help you: