1
votes

I'm trying to save a JS Object to an orientdb class, but the values itself aren't persisting. A "record" is created tough.

I'm following this example: https://github.com/nitrog7/node-orientdb/wiki/Graph-Database#wiki-create-a-new-vertex

node version: v0.10.26

orientdb version: orientdb-community-1.7-rc1

var vertex = {
    '@class':'People',
    'id':'123',
    'name':'Giraldo'
};

db.vertexCreate(vertex)
.then(function(results){
    console.log(results);
})
.error(function(error){
    console.log('Error creating a vertex:', error);
});

Result:

{ '@class': 'p',
  '@type': 'd',
  '@version': 1,
  '@rid': { clusterId: 13, clusterPosition: 48, recordId: '#13:19' } }

Schema: enter image description here

Browse to object: enter image description here

Anyone knows what I'm doing wrong?

1

1 Answers

0
votes

You need to do:

db.open()
     .then(function(){

         //your code goes here

     })

If you have implemented the above code and it is still not working, then I would suggest you to go with executeCommand(). For more info on this, go here.

I hope you have updated to the latest version.