- From: Nolan Lawson <notifications@github.com>
- Date: Thu, 22 Sep 2016 03:56:20 -0700
- To: w3c/IndexedDB <IndexedDB@noreply.github.com>
- Message-ID: <w3c/IndexedDB/issues/45/248869717@github.com>
Due to the popularity of MongoDB, CouchDB has implemented a Mongo-inspired query API, cheekily called [Mango](https://github.com/cloudant/mango). (PouchDB's version is called [pouchdb-find](https://github.com/nolanlawson/pouchdb-find).)
I suggest we implement something similar to tap into web developer familiarity with MongoDB as "the" canonical NoSQL database.
Sketch:
```js
store.get(new IDBQuery({
name: 'Nolan'
}))
```
equivalent to:
```js
store.get(new IDBQuery({
name: {
$eq: 'Nolan'
}
}))
```
Fancier:
```js
store.get(new IDBQuery({
firstName: 'Nolan',
age: {
$lt: 40,
$gte: 30
}
}, {
sort: ['lastName', 'firstName'],
limit: 20,
descending: true,
skip: 1
}))
```
The second argument would be optional. Default sorting can be primary key. Default limit would be Infinity. descending would default to false. skip would default to 0.
I suggest the engine should automatically determine the index to use for a given API (via some handwavy query planner algorithm). If no index is found, then an inefficient in-memory method should be used (possibly logging a warning). Based on experience with PouchDB/Cloudant/CouchDB, a warning is more useful than throwing an error.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/IndexedDB/issues/45#issuecomment-248869717
Received on Thursday, 22 September 2016 10:57:30 UTC