Hi,
through the device i have added two lists and 7 tasks (6 for one list and 1 for another list ) and they all show up in the ui in the right list - nice :)
now I like to do some basic simple operations on the couchbase lite using $ajax for simplicity (we have already zepto loaded).
I understand that the example uses the coax / hoax libraries - but for a very simply use case i like to speak directly to the couchbase lite database with basic $ajax.
I can successfully make a GET:
> $.ajax({
type: "GET",
contentType: "application/json",
success: function (msg) { console.log('succes: ', msg) },
error: function (err){ console.log('error: ', err)}
});
succes: Object {..., title: "task 1", ...}
now I like to get the tasks view in descending order - works(TM):
> $.ajax({
type: "GET",
contentType: "application/json",
success: function (msg) { console.log('succes: ', msg) },
error: function (err){ console.log('error: ', err)}
});
succes:
Object {offset: 0, total_rows: 7, rows: Array[7]}
if I set it to false it shows in ascending order.
fine we got all tasks from all lists - now I like to restrict the tasks to be only those with list_id "969aee54-76e0-46c7-a585-fa5c13d619d6" - in the todo app (index.js) this is done:
window.dbChanged = function() {
config.views(["tasks", {
startkey : [id, {}],
endkey : [id],
descending : true
}], function(err, view) {
...
how to do the same with the above $ajax/uri approach? i have tried:
> var startKey = encodeURIComponent('["969aee54-76e0-46c7-a585-fa5c13d619d6", {}]')
> var endKey = encodeURIComponent('["969aee54-76e0-46c7-a585-fa5c13d619d6"]')
> $.ajax({
type: "GET",
contentType: "application/json",
success: function (msg) { console.log('succes: ', msg) },
error: function (err){ console.log('error: ', err)}
});
succes:
Object {offset: 0, total_rows: 7, rows: Array[7]}
hmm but that gives me 7 tasks i had only expected 6 - any hints/suggestions ?
thanks
//
pelle