如何根据Dynamo数据库表中的条件进行查询? [英] How to query based on condition in dynamo db table?

查看:111
本文介绍了如何根据Dynamo数据库表中的条件进行查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有带有以下项目的表,其中p_id是主分区键,而p_type(String)是主排序键.

I have Table with following items where p_id is Primary partition key and p_type (String) is a Primary sort key.

p_id    p_type    address    name       phone
1221    Men      

我想在这种情况下在节点js函数中编写查询:全选p_type ="men"和address.area ="abc".

I want to write query in node js function with this condition: "select all where p_type ="men" and address.area="abc".

我的地址项目是一张地图,看起来像这样:

my address item is a map and it looks like this:

"address": {
    "M": {
      "area": {
        "S": "abc"
      },
      "city": {
        "S": "Bengaluru"
      },
}

如何实现这一目标.我必须创建全局二级索引吗?如果是,如何创建它.

How to achieve this. do i have to create global secondary index?if yes how to create it.

推荐答案

您不能基于排序键使用Query.

Query起作用.

另一种解决方案是

您可以使用scan运算符代替query

这篇关于如何根据Dynamo数据库表中的条件进行查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆