pouch-vue icon indicating copy to clipboard operation
pouch-vue copied to clipboard

bug: sort does not work on pouch object

Open BananaAcid opened this issue 5 years ago • 2 comments

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

...
data() {},
pouch: {

	posts() {
		return {
			sort: [{header_date: "desc"}]
		}
	}
}

BananaAcid avatar Jun 29 '19 17:06 BananaAcid

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"}]
		}
	}

MDSLKTR avatar Jul 02 '19 21:07 MDSLKTR

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"}],

BananaAcid avatar Jul 03 '19 08:07 BananaAcid