public function saved($model) { $attrs = $model->attributesToArray(); // $this->attributeFilter->filter($attrs); try { $this->dynamoDbClient->putItem(['TableName' => $model->getDynamoDbTableName(), 'Item' => $this->marshaler->marshalItem($attrs)]); } catch (Exception $e) { Log::info($e); } }
/** * {@inheritdoc} */ protected function write(array $record) { $filtered = $this->filterEmptyFields($record['formatted']); if ($this->version === 3) { $formatted = $this->marshaler->marshalItem($filtered); } else { $formatted = $this->client->formatAttributes($filtered); } $this->client->putItem(['TableName' => $this->table, 'Item' => $formatted]); }
public function storeReferralCode($code, $user_id, $timestamp) { $data = ['code' => $code, 'user_id' => $user_id, 'timestamp' => $timestamp]; // TODO error handling $response = $this->client->GetItem(['TableName' => 'tr_referralcodes', 'Key' => ['code' => ['S' => $code]]]); if (!empty($response['Item'])) { throw new \Exception('Code already exists'); } $this->client->PutItem(['TableName' => 'tr_referralcodes', 'Item' => $this->marshaler->marshalItem($data)]); }
/** * Fill the table with data */ protected static function fillTable() { $data = ['key' => 'dev', 'settings' => self::getTestData()]; $marshaler = new Marshaler(); $item = $marshaler->marshalItem($data); self::$dynamodb->putItem(['TableName' => self::TABLE_NAME, 'Item' => $item]); }
public function marshalItem($item) { return $this->marshaler->marshalItem($item); }
/** * @param array $record * @param bool $for_update * * @return mixed */ protected function formatAttributes($record, $for_update = false) { $marshaler = new Marshaler(); if ($for_update) { if (is_array($record)) { foreach ($record as $key => &$value) { $value = ['Action' => 'PUT', 'Value' => $marshaler->marshalValue($value)]; } return $record; } } return $marshaler->marshalItem($record); }
/** * @param Collection $collection * @param $criteria */ public function remove($collection, $criteria) { $args = ['TableName' => $collection, 'Key' => $this->marshaler->marshalItem($criteria)]; $this->getConnection()->deleteItem($args); }
public function deleteItem($tableName, array $key) { $marshaler = new Marshaler(); $this->client->deleteItem(array('TableName' => $this->getRealEnvName($tableName), 'Key' => $marshaler->marshalItem($key))); }
/** * Session destroy handler. * Do not call this method directly. * @param string $id session ID * @return boolean whether session is destroyed successfully */ public function destroySession($id) { $marshaler = new Marshaler(); $keys = []; $keys[$this->idColumn] = $id; try { $this->getClient()->deleteItem(['TableName' => $this->tableName, 'Key' => $marshaler->marshalItem($keys)]); return true; } catch (\Exception $ex) { Yii::error(__CLASS__ . '::' . __METHOD__ . ': ' . $ex->getMessage(), 'yii2dynamodbsession'); return false; } }