ArangoDB lastinsert-Value为NULL

时间:2017-05-02 20:11:27

标签: arangodb

我的查询:

我会使用lastInsert键在2个集合上插入2个数据集。

LET i = (
INSERT {"lvl": @Lvl, "kapitel_key":@Kkey, "plan_key": @Pkey, "xcontent_key": @Xckey, "user_key": @User_key, "templatefile": @Tf } 
    IN xtemplate 
        LET inserted = NEW
            RETURN MERGE(inserted)
    )
    INSERT {"type": "text", "text": "Write here...", "xtemplate_key": i._key, "user_key": @User_key} IN xinhalt

结果:

{
  "type": "text",
  "text": "Write here...",
  "xtemplate_key": null,
  "user_key": "2345632"
}

为什么i._key为空?

Winke winke

1 个答案:

答案 0 :(得分:0)

子查询的结果i来自类型数组而不是文档。 AQL中的每个查询结果都来自类型数组(请参阅docs)。

您必须在第二次INSERT中写i[0]._key而不是i._key

LET i = (
INSERT {"lvl": @Lvl, "kapitel_key":@Kkey, "plan_key": @Pkey, "xcontent_key": @Xckey, "user_key": @User_key, "templatefile": @Tf } 
    IN xtemplate 
        LET inserted = NEW
            RETURN MERGE(inserted)
    )
    INSERT {"type": "text", "text": "Write here...", "xtemplate_key": i[0]._key, "user_key": @User_key} IN xinhalt
相关问题