2016-07-06 24 views
0

是否可以在OrientDB中使用JavaScript編寫的服務器端函數執行OSQL批處理?嘗試做點什麼:如何從JavaScript函數執行OSQL批處理?

var cmd = "begin\n" + 
    "let account = create vertex Account set name = 'Luke'\n" + 
    "let city = select from City where name = 'London'\n" + 
    "let edge = create edge Lives from $account to $city\n" + 
    "commit retry 100\n" + 
    "return $edge" 
db.command(cmd); 

拋出com.orientechnologies.orient.core.command.OCommandExecutorNotFoundException異常。

有什麼建議嗎?

回答

0

您可以使用SQL函數是這樣的: (請注意,var edge已經edg因爲邊緣被改變是一個私字。)

enter image description here


BTW你db.command(cmd);是也有點不對:command()方法需要一個參數來指示使用哪種語言,所以它會是db.command("sql",cmd);

現在,在這種情況下,它也不能正常工作,如上所述,請使用SQL函數。


希望它能幫助,

伊萬