javascript - Use CouchDB with Node.js library -
couchdb uses javascript validate, query, map-reduce , on. i'd know there way use node.js
library in these javascript functions? such use require('http')
or third party modules installed npm
.
thanks.
you can use node.js libraries long don't require node.js-specific libraries http
. example, async works in couchdb. rule of thumb: if it's intended server and client, should good.
you can use commonjs's module.exports
, exports[something]
patterns share code between views. check out the documentation more details.
for example, consider view:
{ _id:"_design/test", views: { lib: { test: "exports.guests = 42;" }, fish_per_person: { map: function(doc){ var guests = require('views/lib/test').guests; // 42 emit(doc.number_of_fish, doc.number_of_fish / guests); } } } }
the fish_per_person
view requires value guests
exported in lib/test
.
Comments
Post a Comment