簡體   English   中英

使用Appsync解析器,AWS dymaodb的嵌套查詢

[英]Nested query using appsync resolver, aws dymaodb

我需要根據第一個查詢的結果在dynamodb上使用aws appsync解析器運行查詢。 我有下面的用戶表。 userTable

第一個查詢:查找其中userId = u1並鍵入= user的項目。 第二個查詢:找到一個項目,其中userId =“從第一個查詢返回的RefId”和status = complete。

我需要在appsync解析器中的一個查詢中執行此操作。


#set( $expValues = {} )
#set($expression="userId = :userId ")
$!{expValues.put(":userId ", { "S" : $ctx.args.input.userId })}


#if(! $util.isNullOrEmpty($ctx.args.input.type))
  #set($expression="$expression and begins_with(type)")
  $!{expValues.put(":type", { "S" : $type})}
#end

{
    "version" : "2018-05-29",
    "operation" : "Query",
    "index" : "mId_mType_index",
    "scanIndexForward" : false,
     "query" : {
        "expression":"$expression",

        #if( !${expValues.isEmpty()} )
            "expressionValues" : $utils.toJson($expValues)
        #end
    },
    #if( ${ctx.args.limit} )
        "limit": ${ctx.args.limit}
    #end
    #if( ${ctx.args.nextToken} )
        ,"nextToken": "${ctx.args.nextToken}"
    #end

}

您可以使用AWS AppSync中的管道求解器來執行此操作。 管道解析器可以具有多個解析器功能,這些功能可以具有自己的數據源。 管道中的下一個函數可以使用上一個解析器的結果。

我需要在appsync解析器中的一個查詢中執行此操作。

我不知道您為什么(想)需要這個,但這是不可能的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM