大佬教程收集整理的这篇文章主要介绍了如何从Perl中的mongoDB返回数据?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
更新:
Example of my data { "_id" : ObjectId("asdhgajsdghajgh"),"country" : "USA" "city" : "Boston" } { "_id" : ObjectId("asdhgajsdghajgh"),"country" : "USA" "city" : "Seattle" } { "_id" : ObjectId("asdhgajsdghajgh"),"country" : "Canada" "city" : "Calgary" } My code my $cursor = $my_collection ->find({ country => 1 }) ; while (my $row = $cursor->next) { print "$row\n"; }
此代码不会产生任何输出.
我想基本上遍历整个集合并按文档阅读文档.
不确定我做错了什么.我用过上面的代码.我在$cursor->旁边更改了$cur->接下来我猜这是一个错字.到目前为止,我很欣赏所有答案.
> MongoDB::Tutorial
> MongoDB::Examples
迭代结果与DBI方式非常相似:
use Data::Printer; use MongoDB; # no query is performed on initialization! my $cursor = $collection ->find({ active => 1,country => 'Canada' }) # filter "active" records from Canada ->sort({ stamp => -1 }) # order by "stamp" attribute,desc. ->limit(1000); # first 1000 records # query & iterate while (my $row = $cur->next) { # it is 'p',from Data::Printer! p $row; }
以上是大佬教程为你收集整理的如何从Perl中的mongoDB返回数据?全部内容,希望文章能够帮你解决如何从Perl中的mongoDB返回数据?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。