Skip to content

How do I sort in Collection.find_one_and_update? #242

@tyteen4a03

Description

@tyteen4a03

I have the following code:

        next_job = yield self.scrapers_coll.find_one_and_update(
            {"state": "enqueued"},
            {
                "$set": {
                    "startTime": time.time(),
                }
            },
            sort=[("createdOn", pymongo.ASCENDING)]
    )

This gives me a TypeError: list indices must be integers or slices, not str.

From going through the source code it looks like TxMongo wants a different format than PyMongo. How do I specify the sort order in this case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions