简体   繁体   English

如何查询一组 AWS-CLI (DynamoDB) 的大小?

[英]How can I query for the size of a set AWS-CLI (DynamoDB)?

There is a column in the table whose data type is set of strings.表中有一列的数据类型是字符串集。 I want to get the results based on the condition on the size of that set.我想根据该集合大小的条件获得结果。 How can I write the filter expression for it in AWS-CLI?如何在 AWS-CLI 中为它编写过滤器表达式?

You can see a complete summary of condition expressions here .您可以在此处查看条件表达式的完整摘要。 The feature you are looking for exists (assuming that by "size" of a set you mean the number of elements) - it is the size() function. Quoting the relevant part of that document:您正在寻找的功能存在(假设集合的“大小”是指元素的数量) - 它是size() function。引用该文档的相关部分:

If the attribute is a Set data type, size returns the number of elements in the set.如果属性是 Set 数据类型,则 size 返回集合中的元素数。

Example: Check whether the product is available in more than one color.示例:检查产品是否有多种颜色可供选择。 The expression attribute value :v_sub is a placeholder for 1.表达式属性值:v_sub是 1 的占位符。

size (Color) <:v_sub

Please remember that although this sort of filtering can avoid sending you the non-matching items, you will still be paying full price for the read of these items, even if not returned.请记住,虽然这种过滤可以避免向您发送不匹配的项目,但您仍然需要为阅读这些项目支付全价,即使没有退回。 So if you need to do this often and to filter out a lot of items, you may want to reconsider your data model to help you more efficiently retrieve only the relevant items.因此,如果您需要经常这样做并过滤掉很多项目,您可能需要重新考虑您的数据 model 以帮助您更有效地检索相关项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM