brikteknologier/seraph

Why is this code throwing a Error: java.util.LinkedHashMap cannot be cast to java.lang.String?

breitmark opened this issue · 1 comments

       const batch = seraph.batch();
       newNode = batch.save({
           _pr: socket.projectId,
           _name: '<empty>'
       });            batch.label(newNode, [classNode]);            batch.relate(data.source.id, data.relation._name, newNode);            batch.commit((err, results) => {            if (err) {
           console.log('Adding node failed:\n' + err);
       } else {
           ...
      } 

I had to fix the formatting to see what was happening in your code, see the questions/comments:

const batch = seraph.batch();

newNode = batch.save({
    _pr: socket.projectId,
    _name: '<empty>'
});

// 1. What is "classNode"?
// This should be a string of the label you wish to apply, not another node.
batch.label(newNode, [classNode]);

// 2. Where are the first and second parameters coming from?
// This could be where the problem is, but it's difficult to tell without knowing what the "data" object is.
batch.relate(data.source.id, data.relation._name, newNode);

batch.commit((err, results) => {
    if (err) {
        console.log('Adding node failed:\n' + err);
    } else {
        // ...
    }
});