Skip to content

Unable to create an edge between two existing nodes #28

@cajus

Description

@cajus

I've just started to play around with the JS client for dgraph. Now I'd like link two nodes by a managed edge like so:

{
  set {
    <0x109> <managed> <0x108> .
  }
}

That works fine in Ratle, but fails with JS:

    const txn = dgraphClient.newTxn();

    try {
        // Add test managed reference
        let p = {
          "uid": "0x109",
          "managed": {
            "uid": "0x108"
          }
        };

        // Run mutation.
        const mu = new dgraph.Mutation();
        mu.setSetJson(p);
        txn.mutate(mu);

        // Commit transaction.
        await txn.commit();
    } finally {
        // Clean up. Calling this after txn.commit() is a no-op
        // and hence safe.
        await txn.discard();
    }

which results in:

{"setJson":"eyJ1aWQiOiIweDEwOSIsIm1hbmFnZWQiOnsidWlkIjoiMHgxMDgifX0=","deleteJson":"","setNquads":"","delNquads":"","setList":[],"delList":[],"startTs":0,"commitNow":false,"ignoreIndexConflict":false}
ERROR:  Error: Transaction has been aborted. Please retry
    at Object.<anonymous> (/home/cajus/tmp/dgraph/node_modules/dgraph-js/lib/errors.js:5:23)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/cajus/tmp/dgraph/node_modules/dgraph-js/lib/client.js:39:16)
    at Module._compile (module.js:660:30)
Mutate response:
{"uidsMap":[],"context":{"startTs":211,"commitTs":0,"aborted":false,"keysList":["32fytna3wc2o4"],"linRead":{"idsMap":[[1,164]]}},"latency":{"parsingNs":26030,"processingNs":8052878,"encodingNs":0}}

As I'm not yet completely familiar with the client, I'm wondering what the error means - and how I can get some more information out of it than the setDebugMode(true) offers.

Metadata

Metadata

Assignees

Labels

kind/bugSomething is broken.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions