Thanks to visit codestin.com
Credit goes to github.com

Skip to content

method for mango query #324

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

method for mango query #324

wants to merge 7 commits into from

Conversation

pirr
Copy link

@pirr pirr commented Sep 27, 2017

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:

  1. Combination operators: http://docs.couchdb.org/en/2.1.0/api/database/find.html#combination-operators, except: $elemMatch, $allMatch.
  2. Condition operators http://docs.couchdb.org/en/2.1.0/api/database/find.html#condition-operators,
    not tested types: Object, Array-$size, Miscellaneous - $mod.
  3. 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.

@pirr pirr mentioned this pull request Sep 27, 2017
@pirr
Copy link
Author

pirr commented Oct 3, 2017

I added support for $elemMatch, maybe $allMatch (not tested).
aaf0395

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.

@djc
Copy link
Owner

djc commented Oct 5, 2017

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?

@pirr
Copy link
Author

pirr commented Oct 5, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants