ivica
ivica

Reputation: 1428

pymongo remove with user defined parameters

I'm trying to build a simple mongodb RESTful API. Client will send JSON data for document removal, which looks like this:

{
    "collectionName": "user",
    "data": {
        "field": "fname",
        "value": "Mike"
    },
    "options": {
        "multi": "false"
    }
}

I would like to pass options from this JSON to pymongo's .remove() function but it's not working. I've tried it like this:

opts = {u'multi': u'false'}
dataBase[collectionName].remove({"some":"condition"},multi=opts['multi'])

it removes all documents that match the given condition, but multi should be false.

What am I doing wrong?

Upvotes: 0

Views: 92

Answers (1)

A. Jesse Jiryu Davis
A. Jesse Jiryu Davis

Reputation: 24007

PyMongo's remove() method doesn't support the "multi" option. The option will be added in the next release of PyMongo, version 2.7. Details are in ticket PYTHON-605.

Upvotes: 1

Related Questions