diff options
author | John Christopher Anderson <jchris@apache.org> | 2009-02-09 01:00:33 +0000 |
---|---|---|
committer | John Christopher Anderson <jchris@apache.org> | 2009-02-09 01:00:33 +0000 |
commit | 3132843214251e3a68b7b3fe89618d323dffa546 (patch) | |
tree | d89e377fb853b51b3d780de508d3699d9867f845 /share/server/main.js | |
parent | 3d5351adb31fea59400179f85fb2dd97b7028ddb (diff) |
row_info object for _list pagination. Thanks benoitc.
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@742220 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'share/server/main.js')
-rw-r--r-- | share/server/main.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/share/server/main.js b/share/server/main.js index 13e85ed8..34b0a353 100644 --- a/share/server/main.js +++ b/share/server/main.js @@ -354,25 +354,32 @@ while (cmd = eval(readline())) { var listFun = funs[0]; var head = cmd[1]; var req = cmd[2]; - row_line[listFun] = 0; + row_line[listFun] = { first_key: null, row_number: 0, prev_key: null }; runRenderFunction(listFun, [head, null, req, null]); break; case "list_row": var listFun = funs[0]; var row = cmd[1]; var req = cmd[2]; - runRenderFunction(listFun, [null, row, req, row_line[listFun]]); - row_line[listFun]++; + var row_info = row_line[listFun]; + runRenderFunction(listFun, [null, row, req, row_info]); + if (row_info.first_key == null) { + row_info.first_key = row.key; + } else { + row_info.prev_key = row.key; + } + row_info.row_number++; + row_line[listFun] = row_info; break; case "list_tail": var listFun = funs[0]; var req = cmd[1]; - var row_number = null; + var row_info = null; try { - row_number = row_line[listFun]; + row_info = row_line[listFun]; delete row_line[listFun]; } catch (e) {} - runRenderFunction(listFun, [null, null, req, row_number]); + runRenderFunction(listFun, [null, null, req, row_info]); break; default: print(toJSON({error: "query_server_error", |