oraclevet opened a new issue #2933:
URL: https://github.com/apache/couchdb/issues/2933
Creating a view(map-reduce) giving "Expression does not eval to a function.
" error.
## Description
Creating a view.
## Steps to Reproduce
code to create the view is as below,
function (doc) {
// first extract what we want to use
const vendors = doc.cve &&
doc.cve.affects &&
doc.cve.affects.vendor &&
doc.cve.affects.vendor.vendor_data;
// since we can't be sure vendor_data does exist
// let's check if it's really an array
if (Array.isArray(vendors) === false)
return; // if not just return and proceed with the next document
// iterate through every "vendor" in that array
vendors.forEach(vendor => {
// let's remember the vendor name
const vendorName = vendor.vendor_name;
// let us also unwrap the product_data
const products = vendor.product &&
vendor.product.product_data;
// again, if products is no array
if (Array.isArray(products) === false)
return; // return and proceed with the next vendor
products.forEach(product => {
// now emit one vendor/product-pair
emit(vendorName, product.product_name);
})
})
}
## Expected Behaviour
view created.
## Your Environment
{"couchdb":"Welcome","version":"3.1.0","git_sha":"ff0feea20","uuid":"b401bbbf089d0d3452eaad6afc60a8f5","features":["access-ready","partitioned","pluggable-storage-engines","reshard","scheduler"],"vendor":{"name":"The
Apache Software Foundation"}}
* CouchDB version used: 3.1.0
* Browser name and version: Chrome/Firefox
* Operating system and version: Ubuntu 18.04 running under WSL.
## Additional Context
[TIP]: # ( Add any other context about the problem here. )
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]