Skip to content

Commit

Permalink
More flexible upsert
Browse files Browse the repository at this point in the history
  • Loading branch information
pterk committed Jul 13, 2019
1 parent 10886ef commit 7866ab2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/GetStream/Stream/Collections.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ public function update($collectionName, $id, array $data)
*/
public function upsert($collectionName, array $data)
{
$response = $this->doRequest('POST', 'meta/', ['data' => [$collectionName => array($data)]]);
if(!is_array($data)){
$data = array($data);
}
$response = $this->doRequest('POST', 'meta/', ['data' => [$collectionName => $data]]);
$body = $response->getBody()->getContents();
return json_decode($body, true);
}
Expand Down

0 comments on commit 7866ab2

Please sign in to comment.