Git Product home page Git Product logo

Comments (5)

dancollins34 avatar dancollins34 commented on May 23, 2024 1

So it looks like you might be able to do something like this in your query:

txn = db.transaction(write=col_name)
result = txn.execute(
    command='''
    function (params) {{
        var db = require('internal').db;
        var a = db.{col}.save({{ '_key': '1', 'val': params.one }});
        var b = db.{col}.save({{ '_key': '2', 'val': params.two }});
        return [a,b];
    }}'''.format(col=col_name),
    params={'one': 3, 'two': 4}
)

And that should return the meta information including the _key on each object.

from python-arango.

zopyx avatar zopyx commented on May 23, 2024

ok, this behavior is documented.

Let me rephrase: how can you obtain the _key of all inserted documents during a transaction?

from python-arango.

dancollins34 avatar dancollins34 commented on May 23, 2024

It looks like this could be handled in a relatively straightforward manner by maintaining a javascript map of outputs to return. However, I think the following code should be moved to transaction.py handle_request (from 104, collections/standard.py insert)

if self._conn.type != 'transaction':
            command = None
        else:
            command = 'db.{}.insert({},{})'.format(
                self._name,
                dumps(document),
                dumps(params)
            )

I'll probably submit a request to do this tonight.

from python-arango.

dancollins34 avatar dancollins34 commented on May 23, 2024

@joowani take a look, but I think I addressed this in #pr66

from python-arango.

joowani avatar joowani commented on May 23, 2024

@zopyx In python-arango version 4.0.0, transactions return job objects allowing result retrieval after commit. You can read more about it here. Please note that 4.0.0 is not backward compatible and you may need to significantly change your code. Cheers.

from python-arango.

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.