如何在OrientDB中创建具有创建顶点的边

时间:2016-12-23 11:05:24

标签: javascript node.js orientdb orientjs

我正在尝试在Purchases类中创建一个顶点及其到Users类顶点的链接。以下示例可以帮助您了解我想要实现的目标。

   function getNewDateByTimeZone($date, $timeZoneOffset)
    {
        /* if the client Time zone is GMT */
        if (!$timeZoneOffset || $timeZoneOffset == 0) {
            $timeZoneOffset = "-0";

        }

        $op = $timeZoneOffset[0];
        $timeZoneOffset = preg_replace('/[^0-9.]+/', '', $timeZoneOffset) * 60;
        $userDate = date($date, time());
        $timeStamp = strtotime($userDate);    

       $offsetTime = $op == '-' ? $timeStamp + $timeZoneOffset : $timeStamp - $timeZoneOffset;



        return date("Y-m-d H:i", $offsetTime);


    }

以上命令产生此错误

Create Edge PurchasedCarts
    FROM
    (CREATE VERTEX Purchases SET guid = "44b4dab7-744a-4f13-ae55-3a563e327de9", accountId = '240059', amount = 44, orderNumber = "1496890", totalItems = 2)
    TO
    (Select @rid from Users)

请帮助我,或者如果你能提出一些其他更好的技巧,我会非常感激。

1 个答案:

答案 0 :(得分:0)

CREATE VERTEX语句不支持此功能,但您可以使用INSERT INTO以及UNSAFE关键字:

insert into PurchasedCarts set out=(insert into Purchases SET guid = "44b4dab7-744a-4f13-ae55-3a563e327de9", accountId = '240059', amount = 44, orderNumber = "1496890", totalItems = 2), in=(select from Users) unsafe

PS

关于目标SELECT使用select from Users而不是select @rid from Users