是否可以在dynamoDB PHP中更新没有哈希键或范围键值的项目? [英] It is possible to update item without hash key or range key value in dynamoDB PHP?

查看:81
本文介绍了是否可以在dynamoDB PHP中更新没有哈希键或范围键值的项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 记录1:[{
business_id:2,
forms:{
f522:{
id : f522,
is_deleted:0,
title: Form 1
},
f8b6:{
id : f8b6,
is_deleted:0,
title: Form 2
},
fw56:{
id: fw56,
is_deleted:0,
title: Form 3
}
}
}]

记录2:[{
business_id:3,
forms:{
f788:{
id: f788,
is_deleted :0,
title: Form 11
},
f6yy:{
id: f6yy,
is_deleted :0,
title:表格12
},
f00i:{
id: f00i,
is_deleted: 0,
title: Form 13
}
}
}]

Record3:[{
business_id: 4,
forms:{
f839:{
id: f839,
is_deleted:0,
title: Form 21
},
f1bc:{
id: f1bc,
is_deleted:0,
title: Form 22
},
f6ac:{
id: f6ac,
is_deleted :0,
title: Form 23
}
}
}]

我在dynamoDB表中存储了3条记录。哈希键是business_id。表单对象是具有子对象(id,is_deleted,标题)的父对象。我不知道business_id的值。但我只有id值 f6yy。我想将is_deleted更新为1个id(值是f6yy)。请建议整个查询。

解决方案

没有这样的查询,因为从逻辑上讲,AWS无法识别您想要修改的条目提供表中条目的键(business_id)。



因此,您需要更改架构并根据查询进行设计,或者将表分解为多个表,这样数据库将类似于

 表1- business_id form_id(例如f6yy等)
表2- form_id form_object(例如{ is_deleted:0, title : Form 1})

现在可以在表2上进行f6yy的更新。 / p>

Record1: [{
"business_id": 2,
"forms": {
    "f522": {
        "id": "f522",
        "is_deleted": 0,
        "title": "Form 1"
        },
    "f8b6": {
        "id": "f8b6",
        "is_deleted": 0,
        "title": "Form 2" 
       },
    "fw56": {
        "id": "fw56",
        "is_deleted": 0,
        "title": "Form 3" 
      }
}
}]

Record2: [{
"business_id": 3,
"forms": {
    "f788": {
        "id": "f788",
        "is_deleted": 0,
        "title": "Form 11"
    },
    "f6yy": {
        "id": "f6yy",
        "is_deleted": 0,
        "title": "Form 12"
    },
    "f00i": {
        "id": "f00i",
        "is_deleted": 0,
        "title": "Form 13"
    }
}
}]

Record3: [{
"business_id": 4,
"forms": {
    "f839": {
        "id": "f839",
        "is_deleted": 0,
        "title": "Form 21"
    },
    "f1bc": {
        "id": "f1bc",
        "is_deleted": 0,
        "title": "Form 22"
    },
    "f6ac": {
        "id": "f6ac",
        "is_deleted": 0,
        "title": "Form 23"
    }
}
}]

I have 3 records stored in dynamoDB table. Hash Key is business_id. forms object is parent object with child objects(id, is_deleted, title). I don't know business_id value. But i have only id value "f6yy". I want update is_deleted to 1 of id(value is f6yy). Please suggest whole query.

解决方案

There is no such query because logically AWS cannot identify the entry you want to modify if it is not provided with the key(business_id) for the entry in the table.

Hence you need to either change your schema and design it according to your queries or decompose the table to multiple tables so the database will be something like

table 1- business_id  form_id(ex. f6yy etc)
table 2- form_id     form_object(ex. {"is_deleted": 0,"title": "Form 1"})

Now the update can be done on table 2 for f6yy.

这篇关于是否可以在dynamoDB PHP中更新没有哈希键或范围键值的项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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