コード例 #1
0
 /**
  * @param ReadModelInterface $data
  *
  * @return mixed
  */
 public function save(ReadModelInterface $data)
 {
     $id = $data->getId();
     $payload = $this->serializer->serialize($data);
     $payload['id'] = $id;
     $item = $this->find($id);
     if ($item) {
         $this->newQuery()->replaceOne(['id' => $id], $payload);
     } else {
         $this->newQuery()->insertOne($payload);
     }
 }
コード例 #2
0
 /**
  * @param ReadModelInterface $model
  */
 public function save(ReadModelInterface $model)
 {
     $this->data[(string) $model->getId()] = $model;
 }
コード例 #3
0
 /**
  * @param ReadModelInterface $model
  */
 public function save(ReadModelInterface $model)
 {
     $this->connection->table($this->table)->updateOrInsert([$this->primaryKey => (string) $model->getId()], $this->serialize($model));
 }
 public function save(ReadModelInterface $data)
 {
     $this->connection->delete(static::TABLE, ['class' => $this->class, 'id' => $data->getId()]);
     $this->connection->insert(static::TABLE, ['class' => $this->class, 'id' => $data->getId(), 'serialized' => json_encode($this->serializer->serialize($data))]);
 }