1

How can I serialize an Origin::Selector object into something that I can feed directly into native Mongo?

Currently, to_json gets me nearly there, but I have to wrap certain types such as Date and ObjectId.

As an example, this is what to_json yields:

{
    "$and": [
        "archived":false,
        "group_id":{
            "$in":[
                "52289c3cb777888350000002"
            ]
        }
    ]
}

but I then have to convert to this before querying mongo:

{
    "$and": [
        "archived":false,
        "group_id":{
            "$in":[
                ObjectId("52289c3cb777888350000002")
            ]
        }
    ]
}

Is there an undocumented way to get the actual protocol query string from a Mongoid::Criteria or Origin::Selector object?

4

1 回答 1

2

恐怕这在当前版本的 Origin 中是不可能的。我看到其他人在要求类似的功能如何查看原始 mongoDB 查询与 Mongoid

无论如何,您可以提交一张票https://github.com/mongoid/origin/issues/new要求该功能吗?

谢谢

于 2013-09-05T17:49:14.870 回答