3

我来自 RDBMS 背景,我在这里有一个应用程序,它需要良好的可扩展性和低延迟。我想试试 CouchDB。但是,我需要检测特定 INSERT 操作何时因唯一键约束而失败。CouchDB 支持这个吗?我看了看文档,但我找不到任何相关的东西。

4

2 回答 2

2

The _id for each document is unique (within the same database), but there are no constraints for other fields in the document.

Particularly, there are no constraints that run across two or more documents.

You can set up validation documents to set up validation rules for documents, but again they are on a document by document basis.

于 2009-06-30T01:36:45.790 回答
1

正如上面的海报所说,除了文档_id之外,其他字段没有任何限制。_id 可以由 couchdb 自动生成,也可以创建自己的。(出于我的目的,我创建了自己的,因为我知道我可以保证密钥的唯一性)。

在最低 API 级别,如果您尝试对现有文档 ID 的 PUT 请求,它将被拒绝并出现 HTTP 409 错误 - 除非您提供现有文档的正确修订版(_rev 属性)。

我不会使用 couchdb 运行任何关键任务,但代码已脱离 Apache 孵化并且非常实用。许多人正在使用它运行网站。

于 2009-06-30T18:04:50.267 回答