KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I need some help with translating the following CouchDB views from javascript to erlang. I need them in erlang, because in javascript the view uses all of the available stack memory and crashes couchjs (see this bugreport https://issues.apache.org/jira/browse/COUCHDB-893 ). The current map functions I have in javascript are: sync/transaction_keys function(doc) { if(doc.doc_type == "Device") { for(key in doc.transactions) emit(key, null); } } and sync/transcation function(doc) { if(doc.doc_type == "Device") { for(key in doc.transactions) { t = doc.transactions[key]; t.device = doc.device; emit(key, t); } } } An example document would be: { "_id": "fcef7b5c-cbe6-31af-8363-2b446a7e4cf2", "_rev": "3-c90abd075404a75744fd3e5e4f04ebad", "device": "fcef7b5c-cbe6-31af-8363-2b446a7e4cf2", "doc_type": "Device", "transactions": { "79fe8630-c0c0-30c6-9913-79b2f93e3e6e": { "timestamp": 1309489169533, "version": 10008, "some_more_data" : "more_data" } "e4678930-c465-76a6-8821-75a3e888765a": { "timestamp": 1309489169533, "version": 10008, "some_more_data" : "more_data" } } } Basically sync/transaction_keys emits all keys of the transaction dictionary and sync/transaction does emit all entries in the transaction dictionary. Unfortunately I never used Erlang before and I need to rewrite that code pretty soon, so any help is very welcomed. Thanks in advance.
Tags (comma-separated)
Save Edits
Cancel