简体   繁体   English

ArangoDB-创建AQL INSERT脚本

[英]ArangoDB - Create AQL INSERT Scripts

I would like to prepare scripts for completing databases. 我想准备用于完成数据库的脚本。 How can I do this? 我怎样才能做到这一点?

Something like that: 像这样:

 INSERT { _class: 'Entity', name: 'First'} IN wholesales
 INSERT { _class: 'Entity', name: 'Second' } IN wholesales
 INSERT { _class: 'Entity', name: 'Three' } IN wholesales
 INSERT { _class: 'Entity', name: 'Four' } IN wholesales

Only one INSERT operation per collection and query is allowed in AQL. AQL中每个集合和查询只允许执行一次INSERT操作。

You can use a loop to make this work however: 您可以使用循环来完成这项工作:

FOR doc IN [
    { _class: 'Entity', name: 'First'},
    { _class: 'Entity', name: 'Second' },
    { _class: 'Entity', name: 'Third' },
    { _class: 'Entity', name: 'Fourth' }
]
INSERT doc INTO wholesales

The documents as well as the collection name can also be passed as bind parameters . 文档以及集合名称也可以作为绑定参数传递。

Query: 查询:

FOR doc IN @docs INSERT doc INTO @@coll

Bind parameters: 绑定参数:

{ "docs": [ { ... }, { ... } ], "@coll": "wholesales" }

Another way to import data is to use arangoimport . 导入数据的另一种方法是使用arangoimport

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM