Code Monkey home page Code Monkey logo

Comments (5)

fiorix avatar fiorix commented on July 23, 2024

It shouldn't be hard to implement. I'd accept a pull request with this.

from txmongo.

danieleapi avatar danieleapi commented on July 23, 2024

I've tested the following and it seems to work. Any comment?

#!/usr/bin/env python
# coding: utf-8

import txmongo
from twisted.internet import defer, reactor

from txmongo._pymongo.son import SON

@defer.inlineCallbacks
def example():
    mongo = yield txmongo.MongoConnection()

    test = mongo.test       # `test` database
    things = test.things    # `things` collection

    # insert new document
    yield things.insert({"foo":"bar", "name":"bar_name"}, safe=True)

    # find_and_modify
    # @see: http://www.mongodb.org/display/DOCS/findAndModify+Command
    spec = SON([
        ("findAndModify", "things"),
        ("query", {"foo":"bar"}),
        ("update", {"$set": {"name": "changed_name"}}),
        ("new", True)])

    result = yield things._database["$cmd"].find_one(spec)
    print result

if __name__ == '__main__':
    example().addCallback(lambda ign: reactor.stop())
    reactor.run()

from txmongo.

danieleapi avatar danieleapi commented on July 23, 2024

I've forked and updated here...
https://github.com/aappii/mongo-async-python-driver/commits/master
first tests are OK...

from txmongo.

fiorix avatar fiorix commented on July 23, 2024

Cool !!
Let me know when you're done so I can review the pull request and merge into master

from txmongo.

danieleapi avatar danieleapi commented on July 23, 2024

done... hope it's ok now... previous pull request had a bug (worked only for findAndModify, not for generic commands)

from txmongo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.