orientdborientjs

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?


Solution

  • You cannot use @ in javascript.

    try

    response[0]['@rid']