Open BananaAcid opened 5 years ago
I believe this should be a good example https://pouchdb.com/api.html#query_index
db.find({
selector: {name: {$eq: 'Mario'}}
}).then(function (result) {
// handle result
}).catch(function (err) {
console.log(err);
});
From the docs: sort defines a list of fields defining how you want to sort. Note that sorted fields also have to be selected in the selector.
posts() {
return {
selector: {header_date: {"$gte": null}}
sort: [{header_date: "desc"}]
}
}
Translating the Pouch examples is not straight forward at first. Might be helpful to be at the readme (sorting, ignoring if null).
I found out, adding selector:{}
does the correct sorting. On PouchDB.
Does not on CouchDB.
Got confused by the readme example:
selector: {type: "person"},
sort: [{name: "asc"}],
This does not work.
Error: Uncaught (in promise) Error: unknown operator "0" - should be one of $eq, $lte, $lt, $gt, $gte, $exists, $ne, $in, $nin, $size, $mod, $regex, $elemMatch, $type, $allMatch or $all