2016-07-24 1 views
0

불어 코드의 사소한 변경은 그것은 나에게 오류를 제공오류가 동적으로

{"doc": doc} -> {"doc": doc,"collection":"test"} 
INSERT @doc INTO users... -> INSERT @doc INTO @collection... 

:

bind parameter 'bind parameter 'collection' has an invalid value or type near '@collection LET newDoc = NEW RET...' at position 1:18' has an invalid value or type (while parsing). Errors: {u'code': 400, u'errorNum': 1553, u'errorMessage': u"bind parameter 'bind parameter 'collection' has an invalid value or type near '@collection LET newDoc = NEW RET...' at position 1:18' has an invalid value or type (while parsing)", u'error': True} 

아무튼 동적으로 또는 내가 어떤 실수를했는지 컬렉션에서 컬렉션을 지원합니까?

답변

2

컬렉션 이름을 주입하는 AQL 지원. 하지만 추가로 @을 접두어로 사용해야하는 경우가 있습니다. 이 수정을 https://docs.arangodb.com/3.0/AQL/Fundamentals/BindParameters.html

, 코드가 작동합니다 :

doc = {"_key": 'some_nice_key', "name": 'Robert', "age": '56'} 
bindVars = {"doc": doc,"@collection":"test"} 
aql = "INSERT @doc INTO @@collection LET newDoc = NEW RETURN newDoc" 
queryResult = db.AQLQuery(aql, bindVars = bindVars)