Commands: Put Document
Example
// Create a new document
$doc = new Category();
$doc->setName("My category");
$doc->setDescription("My category description");
// Create metadata on the document
$docInfo = new DocumentInfo();
$docInfo->setCollection("Categories");
// Convert your entity to a BlittableJsonReaderObject
$jsonDoc = $session->advanced()->getEntityToJson()->convertEntityToJson($doc, $docInfo);
// The Put command (parameters are document ID, changeVector check is null, the document to store)
$command = new PutDocumentCommand("categories/999", null, $jsonDoc);
// RequestExecutor sends the command to the server
$session->advanced()->getRequestExecutor()->execute($command);
Syntax
PutDocumentCommand(string $idOrCopy, ?string $changeVector, array $document);
Parameters | Type | Description |
---|---|---|
idOrCopy | string |
Unique ID under which document will be stored |
changeVector | string (optional) |
Entity changeVector, used for concurrency checks (None to skip check) |
document | array |
The document to store |