eve-arangodb数据层
eve-arango的Python项目详细描述
为与eve rest api框架一起使用的arangodb提供一个数据层。
功能
- 使用arangodb作为文档存储的crud操作
- 支持对边缘文档执行相同的操作以管理关系
- 基于AQL语法的筛选
- 分页和排序
不支持(尚未):
- 正确的图形查询
- 版本控制
- 投影
- 聚合
- 等
安装
$ pip install eve-arango
用法
fromeveimportEvefromeve_arangoimportArangoDBapp=Eve(data=ArangoDB)app.run()
将处理以下设置:
# These are necessary for item lookups to work,# the regex is for the characters allowed in ArangoDB keys.ID_FIELD='_key'ITEM_LOOKUP_FIELD=ID_FIELDITEM_URL='regex("[\w\d\-:.@()+,=;$!*\'%]+")'# If a database named ARANGO_DB's value doesn't exist,# it will be created when the data layer is initialized.ARANGO_DB='database_name'ARANGO_HOST='localhost'ARANGO_PORT=8529# If the keys in DOMAIN do not exist as collection names,# they will be created when the data layer is initialized.# There's no need to add '_id', '_key' or '_rev' fields,# they are added to the schema automatically.# If you specifiy 'edge_collection': True as below,# an edge collection will be created if it does not exist.DOMAIN={'people':{'schema':{'name':{'type':'string'}}},'friends_with':{'edge_collection':True},# ...}
过滤和排序
eve arango使用aql语法通过evewhere参数进行过滤。Mongo样式查询无效。下面是一些有效(url解码)查询及其结果aql的示例:
?where=foo == "bar" # Spaces are optional. # FILTER doc.foo == "bar" ?where=numIN[1,2,3],present!=null # Use , as simple separator between FILTER expressions. # FILTER doc.num IN [1,2,3] # FILTER doc.present != null ?where=a=="a"ANDb=="b"ORc=="c" # AND, OR, NOT can be used to combine expressions. # FILTER doc.a == "a" AND doc.b == "b" OR doc.c == "c"
排序使用常规的eve语法。示例如下:
?sort=name,-age # SORT doc.name, doc.age DESC
贡献
欢迎捐款。打开问题并发送请求。