本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
$util.rds 中的 Amazon RDS協助程式
注意
我們現在主要支援 APPSYNC_JS 執行期及其文件。請考慮在此處使用 APPSYNC_JS 執行期及其指南。
$util.rds
包含協助程式方法,透過清除結果輸出中的外部資料來格式化 Amazon RDS操作。
$util.rds.toJsonString(String serializedSQLResult): String
-
傳回
String
,方法是將字串化原始 Amazon Relational Database Service (AmazonRDS) 資料API操作結果格式轉換為更簡潔的字串。傳回的字串是結果集SQL記錄的序列化清單。每筆記錄都會顯示為鍵值對集合。索引鍵是對應的欄位名稱。如果輸入中的對應陳述式是導致突變的SQL查詢 (例如 INSERT、UPDATE、DELETE),則會傳回空清單。例如,查詢
select * from Books limit 2
提供 Amazon RDS Data 操作的原始結果:{ "sqlStatementResults": [ { "numberOfRecordsUpdated": 0, "records": [ [ { "stringValue": "Mark Twain" }, { "stringValue": "Adventures of Huckleberry Finn" }, { "stringValue": "978-1948132817" } ], [ { "stringValue": "Jack London" }, { "stringValue": "The Call of the Wild" }, { "stringValue": "978-1948132275" } ] ], "columnMetadata": [ { "isSigned": false, "isCurrency": false, "label": "author", "precision": 200, "typeName": "VARCHAR", "scale": 0, "isAutoIncrement": false, "isCaseSensitive": false, "schemaName": "", "tableName": "Books", "type": 12, "nullable": 0, "arrayBaseColumnType": 0, "name": "author" }, { "isSigned": false, "isCurrency": false, "label": "title", "precision": 200, "typeName": "VARCHAR", "scale": 0, "isAutoIncrement": false, "isCaseSensitive": false, "schemaName": "", "tableName": "Books", "type": 12, "nullable": 0, "arrayBaseColumnType": 0, "name": "title" }, { "isSigned": false, "isCurrency": false, "label": "ISBN-13", "precision": 15, "typeName": "VARCHAR", "scale": 0, "isAutoIncrement": false, "isCaseSensitive": false, "schemaName": "", "tableName": "Books", "type": 12, "nullable": 0, "arrayBaseColumnType": 0, "name": "ISBN-13" } ] } ] }
util.rds.toJsonString
是:[ { "author": "Mark Twain", "title": "Adventures of Huckleberry Finn", "ISBN-13": "978-1948132817" }, { "author": "Jack London", "title": "The Call of the Wild", "ISBN-13": "978-1948132275" }, ]
$util.rds.toJsonObject(String serializedSQLResult): Object
-
這與 相同
util.rds.toJsonString
,但結果為 JSONObject
。