method for mango query
I suggest implementation for mango query (only CouchDB 2) http://docs.couchdb.org/en/2.1.0/api/database/find.html.
I used django's filter implementation.
data = db.filter(field__subfield1__...__mango_operator = value)
data = db.filter(Q(field1__subfield1__...__mango_operator = value)
| Q(field2__subfield1__...__mango_operator = value)
& Q(field3__subfield1__...__mango_operator = value))
Work:
- Combination operators: http://docs.couchdb.org/en/2.1.0/api/database/find.html#combination-operators, except: $elemMatch, $allMatch.
- Condition operators http://docs.couchdb.org/en/2.1.0/api/database/find.html#condition-operators, not tested types: Object, Array-$size, Miscellaneous - $mod.
- Sort, limit, fields and other request json object but need test http://docs.couchdb.org/en/2.1.0/api/database/find.html#db-find
I will work on update. In first I would add Array operators - $elemMatch, $allMatch.
I added support for $elemMatch, maybe $allMatch (not tested). aaf039555c3241c355d6d1186f20d9fdd1d833a5
feats: [{subfeat: 1, ...}, {subfeat: 2, ...}]
db.filter(feats_L_elemMatch__subfeat__eq = 1)
feats: ['FOO', 'BAR']
db.filter(feats_L_elemMatch__regex = '(?i)fo')
"_L_" - define "feats" field as list "elemMatch__subfeat__eq" - selector on "subfeat" field
This can be bad implementation. I will be glad to suggestions.
As you can see here, there are some test failures caused by this PR. Can you look at those and make sure they no longer fail?
I fixed doctest. But travis log error:
couchdb.http.ServerError: (400, ('bad_request', 'Referer header required.'))
I not get this error in local test log.