我正在使用riak php客户端并拥有数据类型映射。我想通过keyid删除整个地图。这是我的代码
$location = new Location($itemID, $this->itemBucket);
$map = (new \Command\Builder\FetchMap($this->riak))
->atLocation($location)
->build()
->execute()->getMap();
(new \Command\Builder\UpdateMap($this->riak))
->removeMap($itemID)
->atLocation($location)
->withContext($map->getContext())
->build()
->execute();
但这不起作用。
答案 0 :(得分:1)
我认为你混淆了包含地图对象的KV键和包含嵌套地图的地图键。
此位置将引用"http://riaknode:8098/buckets/$this->itemBucket/keys/$itemID"
$location = new Location($itemID, $this->itemBucket);
这将检索上述存储桶/密钥
包含的mapt对象 $map = (new \Command\Builder\FetchMap($this->riak))
->atLocation($location)
->build()
->execute()->getMap();
这会尝试从返回的地图对象中删除具有键$itemID
的元素
(new \Command\Builder\UpdateMap($this->riak))
->removeMap($itemID)
->atLocation($location)
->withContext($map->getContext())
->build()
->execute();
如果要删除存储在该存储桶/密钥下的整个地图,您可能需要使用\Command\Builder\DeleteObject