CouchDB - 跨视图、跨设计文档、跨数据库共享功能
好吧,事情就是这样。
我有良好的 JS 背景,过去也有过 JS 经验,并且有很多很酷的基本工具,我在一个项目到另一个项目时都随身携带这些工具,就像一个库一样。
我正在尝试制定 CouchDB 的工作。 现在,在习惯了您编写的豪华酷工具并为您简化了语言之后 - 我发现以简单的方式编写许多东西有点令人沮丧。
我正在寻找一种方法,可以将一组有限的、高效的通用工具加载到数据库上下文中,这些工具专注于纯语言,并使该语言的工作更加出色(天哪,不,我不是在谈论jquery 或任何更丰富的库)。
如果最重要的是,可以找到一种方法,我可以将一些我自己的逻辑工具(BL模型函数)添加到couchDB JS引擎的执行上下文中 - 这将呈现出强大而令人钦佩的力量,并使couchDB成为新的像我这样的 JavaScript 爱好者的家。
也许我的目标太低了。 我对即使为特定数据库也可以分配一组扩展的方式感到满意,并且我不介意为每个数据库单独执行此操作。或者更糟糕 - 将其添加到每个设计文档中,这样我就可以在同一个设计文档中教授例如多个视图,什么是 Person
,什么是 Worker
,以及使用它们的方法以可重用的编码方式根据逻辑从它们检索数据。
有人能给我指路吗?
无论您以何种方式指出我 - 我都会非常非常感激不尽。 如果有办法解决所有这些问题——那就太好了。 相信我知道什么逻辑属于哪一层的区别......
你打开了我的可能性 - 我保证使用它们:D
Ok, here's the thing.
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.
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.
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).
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.
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.
Can anybody point me the the way?
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...
You open my possibilities - I promise to use them :D
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
CouchDB 现在支持作为 CommonJS 模块的代码共享。
http://docs.couchbase.org/couchdb -release-1.1/index.html#couchdb-release-1.1-commonjs
http://caolanmcmahon.com/posts/commonjs_modules_in_couchdb
这样,您可以在视图、列表之间共享您的 javascript 模块,并在同一设计文档中显示。 (服务器端)
此外,您可以使用此库在浏览器端加载这些模块:
https://github .com/couchapp/couchapp/blob/master/couchapp/templates/vendor/couchapp/_attachments/jquery.couch.app.js
您可能还想看看 Kanso:
http://kansojs.org/
它确实很好地让你的 javascript 在服务器和客户端。
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
In this way, you can share your javascript modules between views, lists, and shows in the same design doc. (Server-side)
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
You also might want to look at Kanso:
http://kansojs.org/
It does a really good job of making your javascript work seemless between the server and client.
您可以在这里找到一些有用的工具: https://github.com/vivekpathak/casters
运行示例和测试用例可能对您特别有帮助。
You can find some helpful tools here : https://github.com/vivekpathak/casters
The running examples and test cases may particularly help you.