2016-12-04 100 views
1

在couchdb上添加CommonJs模块的确切步骤是什么?couchdb,添加CommonJS模块的程序(显示列表功能)

我读过的教程,如:

https://caolan.org/posts/commonjs_modules_in_couchdb.html

从官方文档:

http://docs.couchdb.org/en/1.6.1/query-server/javascript.html#commonjs-modules

的CommonJS的模块可以被添加到设计文档,像这样:

{ 
    "views": { 
     "lib": { 
     "security": "function user_context(userctx, secobj) { ... }" 
     } 
    }, 
    "validate_doc_update": "function(newdoc, olddoc, userctx, secobj) { 
     user = require('lib/security').user(userctx, secobj); 
     return user.is_admin(); 
    }" 
    "_id": "_design/test" 
} 

但是wh我是否复制或粘贴该代码?我必须保存到文件并添加卷曲吗?在福克斯顿我不知道在哪里。

回答

2

管理CouchDB设计文档通常最好通过如couchapp这样的工具完成。它允许你打包一个文件目录并输出一个CouchDB设计文档。

可以手动编辑JSON在蒲团/ fauxton编辑器,但它是一个痛苦和有othertoolsout there取决于你的工具链。像这样的外部工具也有助于部署,特别是在不同的环境中。