将此 mysql 转换为 couchdb 视图?
我对 couchdb 很陌生,我想基于简单的 mysql 语句创建一个视图。 我找到了这个文档: http://guide.couchdb.org/draft/cookbook.html 但遗憾的是并未包含所有用例。
我的 MySQL 声明:
SELECT `title`, `id`, `author`, `date`, `text` FROM `news` WHERE `date`<=NOW() AND `author`='22' ORDER BY `date` DESC LIMIT 20,10;
非常感谢!
I'm quite new with couchdb and I want to create a view based on a simple mysql statement.
I found this documentation: http://guide.couchdb.org/draft/cookbook.html but there are sadly not all use cases included.
My MySQL-Statement:
SELECT `title`, `id`, `author`, `date`, `text` FROM `news` WHERE `date`<=NOW() AND `author`='22' ORDER BY `date` DESC LIMIT 20,10;
Thank you very much!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用以下地图函数编写一个视图。
现在您可以使用以下 URL 查询视图:
开始键中的日期必须是当前日期时间。无法在 couchdb 中模拟 NOW()。
couchdb 中的视图只是按键排序的键值对列表,它提供了一种访问该列表范围的方法。您需要设计视图,以便可以使用范围查询获得所需的结果。
You need to write a view with the following map function.
Now you can query the view using the following URL:
The date in the start key must be the current datetime. There is no way to emulate
NOW()
in couchdb.A view in couchdb is just a list of key-value pairs sorted by key and it provides a way to access a range of that list. You need to design your view such that you can get the results that you need using a range query.