user1879531
user1879531

Reputation: 153

create edge in orientjs soon after inserting a vertex

I am trying to create an edge in the callback function after inserting a vertex. below is the code that I used.

db.query('insert into Post content :Post',{
        params: {
            Post: post
        }
    }).then(function(response){
            db.query('create edge from :PostId to :UserId',{
            params: {
                PostId : response[0].@rid,
                UserId : req.body.userid;
            }
        }).then(function(result){
            console.log('create edge'+result);
        });
        return res.json(response);
    }); 

But it throws an error saying Unexpected token ILLEGAL pointing to @rid. Am I doing anything wrong here? or Is there an alternate way to create an edge?

Upvotes: 1

Views: 360

Answers (1)

wolf4ood
wolf4ood

Reputation: 1949

You cannot use @ in javascript.

try

response[0]['@rid']

Upvotes: 2

Related Questions