Skip to content

upsert and get are not implemented #35

@juongithub

Description

@juongithub

The upsert and get commands are not implemented, they might be useful.
The upsert command is similar to save:

public function upsert( $document ) {
  $document = (object) $document;
  $partitionValue = $this->findPartitionValue( $document );
  $document = json_encode( $document );
  
  $headers = $this->triggersAsHeaders( "create" );
  
  $headers['x-ms-documentdb-is-upsert'] = 'True';
  
  $result = $this->collection->createDocument( $document, $partitionValue, $headers );
  
  $resultObj = json_decode( $result );
  
  if ( isset( $resultObj->code ) && isset( $resultObj->message ) ) {
	  throw new Exception( "$resultObj->code : $resultObj->message" );
  }
  
  return $resultObj->_rid ?? null;
}

While the get should simply take advantage of the CosmoDB getDocument method already implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions