brikteknologier / seraph

A thin and familiar layer between node and neo4j's REST api.
MIT License
309 stars 59 forks source link

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

Open breitmark opened 6 years ago

breitmark commented 6 years ago
       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 {
           ...
      } 
parties commented 5 years ago

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 {
        // ...
    }
});