Search code examples
pythoneve

Python Eve - Query Embedded Data Relation


I have the following resource defined:

item = {
    'wrapper': {
        'type': 'dict',
        'schema': {
            'element': {
                'type': 'objectid',
                'data_relation': {
                    'resource': 'code',
                    'field': '_id',
                    'embeddable': True,
                },
            },
        },
    },
}

When I try to query using the objectid, I get empty list.

http://127.0.0.1:5000/item?where={"wrapper.element":"5834987589b0dc353b72c27d"}

5834987589b0dc353b72c27d is the valid _id for the element.

If I move the data relation out of the embedded document I can query it as expected

Is there anyway to do this with an embedded data relation?


Solution

  • I had a problem where the _id was being stored as a string rather than an ObjectId(), this broke the query