没有服务器端的CouchApp或具有xdomain问题的CouchDB后端? [英] CouchApp without Server side or CouchDB backend with xdomain issues?

查看:84
本文介绍了没有服务器端的CouchApp或具有xdomain问题的CouchDB后端?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用CouchDB和CouchApp已有一段时间了。我正在计划将其用于正在开发的新网站项目。

I have been playing with CouchDB and CouchApp for a little while now. I am planning on using it for a new web site project I'm working on.


  1. 从可伸缩性的角度来看,我喜欢CouchApp的想法。

  1. From a scalability viewpoint I love the idea of CouchApp.

缺点是没有服务器端代码,有些事情(例如oAuth身份验证)在客户端很难完成。在某些时候,我确定我需要一些描述性的服务器端代码-我想您可以看看Node.js,但现在不愿意。

The downside is that with no server side code there are some things (like oAuth authentication) that are hard to do on the client side. At some point I'm sure I will need some server side code of some description - I guess you can then look at Node.js but would rather not at this point.

将CouchDB纯粹用作后端解决方案,同时从另一台服务器提供页面也很合适,但是这里的缺点是跨域问题使您无法轻松使用内置的CouchDB API。 / p>

Using CouchDB purely as a backend solution while your pages are served from another server is also a great fit but the downside here is that the cross domain issues prevent you from easily using the built in CouchDB API.

那么有人能解决这两个缺点之一吗?

So does anyone have a solution to one of these two downsides?

您能否以某种方式从CouchApp提供服务器端代码(甚至是PHP也是一个胜利),还是可以以某种方式使用一个单独的站点来服务您的页面,但克服了跨域问题?

Can you somehow serve server side code (even PHP would be a win) from CouchApp or can you somehow use a separate site to serve your pages but overcome the cross domain issue?

我真的试图保持解决方案尽可能干净(和可扩展),并且CouchDB的一大优点是超级简单,超快的API,所以我真的不希望在它周围使用包装器-除非它不会妨碍性能/可扩展性。

I am really trying to keep the solution as clean (and as scalable) as possible and one of the great things about CouchDB is the super simple, super fast API so I don't really want to use a wrapper around it - unless it doesn't hinder the performance/scalability.

欢迎您提出意见。

推荐答案

由于CouchDB使用基于HTTP的API,因此有多种方法可以混合和匹配服务器端代码(node.js,PHP,

Because CouchDB uses an HTTP-based API there are several ways to "mix and match" server-side code (node.js, PHP, etc) with your CouchApp.

我将选项分为三类:


  1. 首先,您现在拥有的是两层体系结构:CouchDB提供的Browser + CouchApp。对于只需要浏览器和CouchDB可以提供的功能的应用程序来说,这是一个很好的解决方案,但是一旦您需要发送电子邮件,调整图像大小或从另一个不需要的数据库中获取数据,就需要另一个层次

  2. 接下来是3层架构:浏览器+ Apache / PHP(或类似堆栈)+ CouchDB。这是更传统的选项(即LAMP)。对于逐渐迁移到CouchDB来说是很好的选择,但是从长远来看,必须通过第二个HTTP服务器(可能是代理服务器)或服务器端脚本语言(如PHP)来路由所有内容,这会变得很麻烦。

  3. 最后,也是我最喜欢的是2.5层体系结构:浏览器+ CouchDB +外部或_changes基于提要的操作。在这种情况下,PHP(或类似)充当CouchDB的某种服务提供者。可以通过使PHP监视_changes提要中某些类型的文档及其更改(例如,图像上传,电子邮件文档)来触发操作,或者可以将CouchDB设置为 ping _external处理程序以对该文档进行进一步处理或其附件。从本质上讲,这就是ouchdb-lucene的工作方式,它可以观察更新并在更新发生时或定期对其进行操作。

您可以在下面找到有关_changes提要和_external处理程序的更多信息:

You can find out more about the _changes feed and _external handlers below:

  • _changes feed: http://guide.couchdb.org/draft/notifications.html
  • _external handlers: http://wiki.apache.org/couchdb/ExternalProcesses

关于其价值,我将在本周三的 PHP和CouchDB网络广播。您的问题将对网络广播结尾的讨论有所帮助。

For what its worth, I'll be discussing these three options this coming Wednesday in a PHP and CouchDB Webcast. Your questions would be a valuable addition to the discussion at the end of the webcast.

我很想知道您的CouchApp结果如何,以及如何解决问题您在上面提到过。

I'd love to know how your CouchApp turns out, and how you solve the problems you mentioned above.

这篇关于没有服务器端的CouchApp或具有xdomain问题的CouchDB后端?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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