0

Trying to set a static filter in python eve using Mongodb. I am looking to return a list of distinct categories based on a content collection.

category = {
  'datasource': {
     'source': 'content',
     #'filter': {'category': {'$distinct': True} },
     'projection': {'category': 1},
    }
}

The above is causing an error (when the filter line is commented out). Any help much appreciated.

cg1207
  • 13
  • 3
  • Can you show the error? – Kobi K Apr 01 '14 at 10:32
  • Its just a standard 500 Internal server error when the category endpoint is requested. I am guessing the $distinct value is not valid (it was nothing more than a guess as to the allowed values;) – cg1207 Apr 01 '14 at 11:28

1 Answers1

0

If you run your Eve application in debug mode (app.run(Debug=True), or set DEBUG = True in your settings file, you will get to see what the actual error is:

OperationFailure: database error: invalid operator: $distinct

MongoDB distinct is an Aggregation Framework command, not a query operator like, for example, $exists (which in fact you can use to set up a Eve static filter).

Nicola Iarocci
  • 6,606
  • 1
  • 20
  • 33
  • 1
    Thanks for the debug tip Nicola. I did in fact use the example in the docs where $exists was given as an example, but do realise that I am was not looking for a query operator. I included it above to help illustrate what I was trying to achieve. Any pointers in how I return a distinct data set using eve though? (thanks for a great framework btw ;) – cg1207 Apr 01 '14 at 14:57