简体   繁体   English

跳过和限制功能在Rails Rake文件中不起作用

[英]skip and limit function not work in rails rake file

Hi am learner of rails and mongodb. 大家好,我是Rails和mongodb的学习者。 i am doing application on rails with mongodb as backend. 我正在使用mongodb作为后端在Rails上进行应用程序。 am having huge content of data to retrieve on single request at the time am having error is "cursor error", for that i used a trick is to partition of all data to small content. 我当时有巨大的数据内容要在单个请求上检索,当时我的错误是“光标错误”,因为我使用的技巧是将所有数据划分为小内容。 on that concept am having a bug, my code is to separate 关于这个概念有一个错误,我的代码是分开

     competitionsAry = NFL_Competition.where(sdi_sport_id: teamSdi_Sport_id)

 puts "Total competitions:" + competitionsAry.count.to_s // it has 2330 count on this step  

      execCount = competitionsAry.count / 100

      if competitionsAry.count % 100 != 0

          execCount += 1

      end      

      execCount.times do |ctr|

        skipValue = ctr + 100

        competitions = competitionsAry.skip(skipValue).limit(100)

 puts "Now the competition length is: " + competitions.length.to_s // here also same amount of 2330 data

i know "competitions = competitionsAry.skip(skipValue).limit(100)" here is the problem. 我知道“竞争= CompetitionsAry.skip(skipValue).limit(100)”就是问题所在。 skip and limits functions are not working. 跳过和限制功能不起作用。 even i tried "competitions = NFL_Competition.skip(skipValue).limit(100)" no result what am exception can anyone help how to solve this and how to use skip and limit function on rails. 即使我尝试了“竞赛= NFL_Competition.skip(skipValue).limit(100)”,也没有结果是什么例外,任何人都可以帮助解决此问题以及如何在滑轨上使用跳过和限制功能。 thank you in advance. 先感谢您。

是的,我明白了,我为此使用了ruby array slice的概念。

competitions = competitionsAry[skipValue,100]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM