couchdb 视图绑定在两个数据库之间?
假设我的沙发实例上有多个数据库(在我的例子中是用户帐户数据库和登录会话数据库),会话具有与用户数据库中的字段相对应的字段。有没有办法创建视图,或进行包含这种关联的调用,或者只需使用外部脚本来完成?为了更清楚,这里有一个例子。
Account db:
{
"_id": "78555fdfdd345debf427373f9dfaeca4",
...
"username" : "bob"
}
Sessions db:
{
"_id": "78555fdfdd345debf427373f9dfcd7ae",
..
"accountId": "78555fdfdd345debf427373f9dfaeca4",
"username": "bob"
}
我可以使用emit或类似的东西将所有这些信息捆绑在一个调用中吗?
Say I have several databases on my couch instance (in my case a user account database and login session database) The sessions have fields corresponding to a field in the user database. Is there a way to create a view, or make a call that encompasses this correlation, or would it just have to be done with an external script? To be more clear, here's an example.
Account db:
{
"_id": "78555fdfdd345debf427373f9dfaeca4",
...
"username" : "bob"
}
Sessions db:
{
"_id": "78555fdfdd345debf427373f9dfcd7ae",
..
"accountId": "78555fdfdd345debf427373f9dfaeca4",
"username": "bob"
}
Can I use emit or something like that to bundle together all this information in one call?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可以,但是常见的解决方法是为文档设置“类型”属性。
例如......
然后在你看来:
No, however a common workaround is to have a "type" attribute for documents.
For example...
And then in your views:
不,不幸的是,无法连接多个数据库中的数据。
每个视图都应该是独立的,否则更新 1 个数据库中的任何文档将立即需要触发每个其他数据库中的视图索引在所有情况下重新计算。
No, unfortunately there is no way to connect data from multiple databases.
Each view is supposed to be self-contained, otherwise updating any document in 1 database will immediately need to trigger views indexes in every other database to be recalculated in all cases.