MongoCursor  
The MongoDB query cursor object
Updated May 8, 2010 by neoman...@gmail.com

Synopsis

require('mongo')
-- query all the values in the namespace 'test.values' where a > 10
local q1 = assert(db:query('test.values', {a = {['$gt'] = 10}}))

-- loop through the result set
for result in q1:results() do
       
print(result.a)
       
print(result.b)
end

-- query all the values in the namespace 'test.values' where a < 10 (JSON version)
local q2 = assert(db:query('test.values', "{'a': {'$lt': 10}}"))

local result = q2:next()
while result do
       
print(result.a)
       
print(result.b)

        result
= q2:next()
end

Methods

result = query:next()

Returns the next single result set (as a table) in the results of a query operation.

iterator = query:results()

Similar to the next method but returns an iterator function (as opposed to a table) that can be used in a for loop.

has_more = cursor:has_more(in_current_batch)

  • pass true to call moreInCurrentBatch (mongo >=1.5)

it_count = cursor:itcount()

is_dead = cursor:is_dead()

is_tailable = cursor:is_tailable()

has_result_flag = cursor:has_result_flag()

id = cursor:get_id()

::...
免责声明:
当前网页内容, 由 大妈 ZoomQuiet 使用工具: ScrapBook :: Firefox Extension 人工从互联网中收集并分享;
内容版权归原作者所有;
本人对内容的有效性/合法性不承担任何强制性责任.
若有不妥, 欢迎评注提醒:

或是邮件反馈可也:
askdama[AT]googlegroups.com


订阅 substack 体验古早写作:


点击注册~> 获得 100$ 体验券: DigitalOcean Referral Badge

关注公众号, 持续获得相关各种嗯哼:
zoomquiet


自怼圈/年度番新

DU22.4
关于 ~ DebugUself with DAMA ;-)
粤ICP备18025058号-1
公安备案号: 44049002000656 ...::