我正在使用 dynamoose,查询返回以下输出
[ Document { cost: 100 },
lastKey: undefined,
count: 1,
queriedCount: undefined,
timesQueried: 1 ]
当我尝试做时typeof(output)
,它会返回Object
当我尝试做时Object.keys(output)
,它会返回[ '0', 'lastKey', 'count', 'queriedCount', 'timesQueried' ]
当我这样做时Object.entries(output)
,它会返回[ [ '0', Document { cost: 100 } ],[ 'lastKey', undefined ], [ 'count', 1 ], [ 'queriedCount', undefined ], [ 'timesQueried', 1 ] ]
为了我的使用,我需要一个看起来像这样的对象,{cost: 100}
目前我正在使用
JSON.parse(JSON.stringify(output))
这给了我
[ { cost: 100 } ]
我还没有遇到没有键值对的对象(我是自学的),所以我不知道如何解决这个问题。目前的方法似乎效率低下而且有点错误。请告诉我如何以正确的方式做到这一点