在 java 驱动程序中为 arangoDB 绑定集合
Bind collection in java driver for arangoDB
我正在为 ArangoDB 使用 java 驱动程序。
我在一个字符串变量中有一个 JSON 数组,我希望将它插入到 table 中。我使用以下查询
for r in @fromCollection insert r into @targetCollection
在 Web 界面中插入很顺利,但在 Java 中,我在绑定这 2 个变量时遇到了麻烦 -
1553 - ERROR_QUERY_BIND_PARAMETER_TYPE
Will be raised when a bind parameter has an invalid value or type
你能帮我在 ArangoDB 中将集合名称绑定为变量吗?
我不确定您的 JSON 字符串变量如何在此查询中发挥作用。
当您想插入字符串变量中包含的 JSON 个文档时,您可以使用 importDocuments(String)
方法:
ArangoDB arango = new ArangoDB.Builder().build();
arango.db().collection("myCollection").importDocuments(jsonArray);
与您查询的问题相关:
存在用于注入集合名称的特殊类型的绑定参数。这种类型的绑定参数的名称以附加的 @
符号为前缀(因此在查询中使用绑定参数时,必须使用两个 @
符号)。有关绑定参数的更多信息,请查看 here
您的查询必须看起来:
for r in @@fromCollection insert r into @@targetCollection
在 Java 中看起来如下:
ArangoDB arango = new ArangoDB.Builder().build();
Map<String, Object> bindVars = new HashMap<>();
bindVars.put("@fromCollection", "...");
bindVars.put("@toCollection", "...");
arango.db().query("for r in @@fromCollection insert r into @@targetCollection", bindVars, null, BaseDocument.class)
我正在为 ArangoDB 使用 java 驱动程序。 我在一个字符串变量中有一个 JSON 数组,我希望将它插入到 table 中。我使用以下查询
for r in @fromCollection insert r into @targetCollection
在 Web 界面中插入很顺利,但在 Java 中,我在绑定这 2 个变量时遇到了麻烦 -
1553 - ERROR_QUERY_BIND_PARAMETER_TYPE
Will be raised when a bind parameter has an invalid value or type
你能帮我在 ArangoDB 中将集合名称绑定为变量吗?
我不确定您的 JSON 字符串变量如何在此查询中发挥作用。
当您想插入字符串变量中包含的 JSON 个文档时,您可以使用 importDocuments(String)
方法:
ArangoDB arango = new ArangoDB.Builder().build();
arango.db().collection("myCollection").importDocuments(jsonArray);
与您查询的问题相关:
存在用于注入集合名称的特殊类型的绑定参数。这种类型的绑定参数的名称以附加的 @
符号为前缀(因此在查询中使用绑定参数时,必须使用两个 @
符号)。有关绑定参数的更多信息,请查看 here
您的查询必须看起来:
for r in @@fromCollection insert r into @@targetCollection
在 Java 中看起来如下:
ArangoDB arango = new ArangoDB.Builder().build();
Map<String, Object> bindVars = new HashMap<>();
bindVars.put("@fromCollection", "...");
bindVars.put("@toCollection", "...");
arango.db().query("for r in @@fromCollection insert r into @@targetCollection", bindVars, null, BaseDocument.class)