Commit cd5cf1e5 authored by Tristan Cavelier's avatar Tristan Cavelier

make limit act like sql limit

parent 385cbbcf
...@@ -233,9 +233,13 @@ function limit(limit_option, list, clone) { ...@@ -233,9 +233,13 @@ function limit(limit_option, list, clone) {
if (clone) { if (clone) {
list = deepClone(list); list = deepClone(list);
} }
list.splice(0, limit_option[0]); if (limit_option.length > 1) {
if (limit_option[1]) { list.splice(0, limit_option[0]);
list.splice(limit_option[1]); if (limit_option[1]) {
list.length = limit_option[1];
}
} else if (limit_option.length === 1) {
list.length = limit_option[0];
} }
return list; return list;
} }
......
...@@ -565,7 +565,7 @@ ...@@ -565,7 +565,7 @@
"include_docs": true, "include_docs": true,
"sort_on": [['title', 'ascending'], ['date', 'descending']], "sort_on": [['title', 'ascending'], ['date', 'descending']],
"select_list": ['title', 'date'], "select_list": ['title', 'date'],
"limit": [1] // ==> equal [1, 3] in this case "limit": [1, 3]
}); });
}).always(function (answer) { }).always(function (answer) {
......
...@@ -116,7 +116,7 @@ ...@@ -116,7 +116,7 @@
"include_docs": true, "include_docs": true,
"sort_on": [['title', 'ascending'], ['date', 'descending']], "sort_on": [['title', 'ascending'], ['date', 'descending']],
"select_list": ['title', 'date'], "select_list": ['title', 'date'],
"limit": [1] // ==> equal [1, 3] in this case "limit": [1, 3]
}); });
}).always(function (answer) { }).always(function (answer) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment