You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by Apache Wiki <wi...@apache.org> on 2010/07/30 17:38:23 UTC

[Couchdb Wiki] Trivial Update of "CommonJS_Modules" by DaveCottlehuber

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "CommonJS_Modules" page has been changed by DaveCottlehuber.
The comment on this change is: clarify why CommonJS modules can't be used in views.
http://wiki.apache.org/couchdb/CommonJS_Modules?action=diff&rev1=3&rev2=4

--------------------------------------------------

  ## page was renamed from commonjs_modules
  = CommonJS Modules =
+ As of the 0.11 release of CouchDB you can use CommonJS 1.0 modules in your show, list, update, and validation functions. map and reduce functions '''can NOT''' use modules. This is because view results are stored in the B-tree, and if the module (which is now external to the view itself) was updated, CouchDB would not be aware of the changed module, & therefore would not recompute the view.
- 
- As of the 0.11 release of CouchDB you can use CommonJS 1.0 modules in your show, list, update, and validation functions. map and reduce functions '''can NOT''' use modules.
  
  {{{#!highlight JavaScript
    {
-    _id:"_design/test", 
+    _id:"_design/test",
     language: "javascript",
     whatever : {
       stringzone : "exports.string = 'plankton';",
@@ -22, +21 @@

     }
    }
  }}}
- 
  Within a show function you can require CommonJS modules that are defined within object in your design document. The id you pass to require() is a / delimited list of property names to resolve the module string within the design document.
  
  All imports are relative to the design document root unless they start with ./ or ../, these are referred to as "relative require" statements. Relative require statements only work within CommonJS modules they cannot be used directly inside your show, list, update and validation functions.