CouchDB-跨视图,跨设计文档,跨数据库共享功能 [英] CouchDB - share functions across views, across design documents, across databases

查看:123
本文介绍了CouchDB-跨视图,跨设计文档,跨数据库共享功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好,这是东西.

我具有良好的JS背景,过去曾分享过JS,并且从项目到项目都有很多很酷的准系统工具,就像图书馆一样.

I have a good JS background, had my share of JS in the past, and have lots of cool bare-bones tools I take with me from project to project that act like a library.

我正在尝试制定CouchDB的工作方式. 现在,在习惯了为您编写并简化语言的豪华工具之后,我发现以裸露的方式编写许多东西有点令人沮丧.

I'm trying to formulate work with CouchDB. Now, after getting used to luxury of cool tools that you wrote and simplify the language for you - I find it a little frustrating to write many things in bare-bones manner.

我正在寻找一种方法,可以将一组有限,高效且通用的工具加载到数据库上下文中,这些工具集中在纯语言上,并使使用该语言的工作变得更加时髦(而且,天哪,不,即时消息不在谈论jquery或其他任何更繁忙的库).

I'm looking for a way I can load to the database context a limited, highly efficient and generic set of tools that focus on the pure language and makes the work with the language much more groovy (and gosh, no, im not talking about jquery or any of the even more busty libraries out there).

如果最重要的是,可以找到一种方法,可以将一些我自己的逻辑工具(BL模型函数)添加到ouchDB JS引擎的执行上下文中,它将展现出强大而令人钦佩的功能,并且使couchDB成为像我这样的JavaScript-er的新家.

If on top of that, there could be found a way where I can add to the execution context of the couchDB JS engine some of my own logic tools (BL model functions) - it would present a great and admirable power and make couchDB the new home for a JavaScript-er like me.

也许我的目标太低了. 我对即使为特定数据库也可以分配一组扩展名的方式感到满意,而且我不介意为每个数据库单独进行分配.或更糟糕的是-将其添加到每个设计文档中,因此我可以在同一个设计文档中教几个视图,例如,Person是什么,Worker是什么,并使用它们的方法根据它们从中检索数据.逻辑以可重复使用的方式编码.

Maybe I'm aiming too low. I'd be satisfied with a way I can allocate a set of extensions even for a specific database, and I don't mind do it for every database in separate. Or worse - to add it to every design document, so I can teach for example several views in the same design-doc what a Person is, what a Worker is, and use their methods to retrieve data from them according to logic in a reusably coded manner.

有人能指点我吗?

无论您如何指向我-我都会非常感谢. 如果有所有这些方法-那太好了. 相信我知道什么逻辑属于哪一层的区别...

Whatever way you can point me - I'll be very verrry grateful. If there are ways for all of these - then great. Trust me to know the difference of what logic belongs to what layer...

您打开了我的可能性-我保证会使用它们:D

You open my possibilities - I promise to use them :D

推荐答案

CouchDB现在支持将代码共享作为CommonJS模块.

CouchDB now supports code sharing as CommonJS modules.

http://docs.couchbase. org/couchdb-release-1.1/index.html#couchdb-release-1.1-commonjs

http://caolanmcmahon.com/posts/commonjs_modules_in_couchdb

通过这种方式,您可以在同一设计文档中的视图,列表和显示之间共享javascript模块. (服务器端)

In this way, you can share your javascript modules between views, lists, and shows in the same design doc. (Server-side)

此外,您可以使用以下库在浏览器端加载这些模块: https://github .com/couchapp/couchapp/blob/master/couchapp/templates/vendor/couchapp/_attachments/jquery.couch.app.js

Also, you can load these modules on the browser side with this library: https://github.com/couchapp/couchapp/blob/master/couchapp/templates/vendor/couchapp/_attachments/jquery.couch.app.js

您可能还想看看Kanso:

You also might want to look at Kanso:

http://kansojs.org/

在服务器和客户端之间使您的javascript正常工作确实做得很好.

It does a really good job of making your javascript work seemless between the server and client.

这篇关于CouchDB-跨视图,跨设计文档,跨数据库共享功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆