Right now there's not a specific interface for findAndModify
, but you can invoke arbitrary database commands with this method:
-[MongoConnection runCommandWithDictionary:onDatabaseName:error:]
The 10gen docs for findAndModify give this example command:
{
findAndModify: "people",
query: { name: "Tom", state: "active", rating: { $gt: 10 } },
sort: { rating: 1 },
update: { $inc: { score: 1 } }
}
If you create a dictionary with that structure and pass it to -runCommandWithDictionary
you should get the result you want.