我是铁路和mongodb的学习者。我正在使用mongodb作为后端在rails上进行应用程序。 我有一个巨大的数据内容,在有错误的时候在单个请求上检索是“游标错误”,因为我使用的技巧是将所有数据分区为小内容。关于那个概念我有一个错误,我的代码是分开
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
我知道“比赛=竞赛Ary.skip(skipValue).limit(100)”这是问题所在。 跳过和限制功能不起作用。即使我尝试“竞争= NFL_Competition.skip(skipValue).limit(100)”没有结果什么是异常可以任何人帮助如何解决这个以及如何在rails上使用跳过和限制功能。提前谢谢你。
答案 0 :(得分:0)
你知道我用它来使用ruby数组切片概念。
competitions = competitionsAry[skipValue,100]