Oihana PHP Arango

DocumentsCommand extends Kernel uses DocumentsCommandActions, ChainedCommandsTrait

Manages Documents within an Documents collection via console commands.

This command provides a command-line interface (CLI) for common CRUD (Create, Read, Update, Delete) operations on a specific ArangoDB document collection, likely representing "Things". It leverages the Symfony Console component for command-line interaction and a custom Documents model for database operations.

It acts as a wrapper for various document management functionalities, allowing users to count, get, insert, delete, check existence, list, and truncate documents directly from the command line.

Tags
example

Set the IoC definition of the places command

return
[
 Commands::PLACES => fn( Container $container ) => new DocumentsCommand
 (
     Commands::PLACES ,
     $container ,
     [
         DocumentsCommandParam::DOCUMENTS   => Models::PLACES ,
         DocumentsCommandParam::EXCLUDES    => [ Prop::AT_CONTEXT  , Prop::AT_TYPE , Prop::AT_ID ] ,
         DocumentsCommandParam::FIELDS      => [ Prop::_KEY , Prop::NAME , Prop::CREATED , Prop::MODIFIED ] ,
         DocumentsCommandParam::DESCRIPTION => 'The places collection helper.' ,
         DocumentsCommandParam::HELP        => 'This command allows search and manage the places collection.' ,
     ]
 )
];

#### Executes the command with it's options

List all documents
```shell
$ php bin/console.php places -v
$ php bin/console.php places list
$ php bin/console.php places list -v

Calculates the number of documents in the collection

$ php bin/console.php places count
$ php bin/console.php places count --optimized
$ php bin/console.php places count -o

Get a specific document

$ php bin/console.php places get 59943726 -v
$ php bin/console.php places get 59943726 --verbose

Get the last document in the collection (by default with the property 'modified')

$ php bin/console.php places last
$ php bin/console.php places last created

Check if a document or a set of documents exists.

$ php bin/console.php places exist 59918826
$ php bin/console.php places exist 59918826 59943726 555 60280105

Insert a new document in the collection

$ php bin/console.php places insert '{"id":"55525","name":"Marseille","path":"places","address":{"postalCode":"13013"}}' -v

Update an existing document in the collection

$ php bin/console.php places update 55525 '{"name":"Marseille !"}'

Replace an existing document in the collection

$ php bin/console.php places replace 55525 '{"id":"55525",name":"Marseille !","path":"places","address":{"postalCode":"13012"}}' -v

Delete a document in the collection

$ php bin/console.php places delete 60280116

Delete a set of documents in the collection

$ php bin/console.php places delete 60280116 60280105

[warning] Remove all documents in the collection

$ php bin/console.php places truncate --accept true

Table of Contents

Methods

__construct()  : mixed
Creates a new DocumentsCommand instance.
configure()  : void
Configures the current command.
execute()  : int
Executes the current command.

Methods

__construct()

Creates a new DocumentsCommand instance.

public __construct(string|null $name[, Container|null $container = null ][, array<string|int, mixed> $init = [] ]) : mixed
Parameters
$name : string|null
$container : Container|null = null
$init : array<string|int, mixed> = []
Tags
throws
ContainerExceptionInterface
NotFoundExceptionInterface
DependencyException
NotFoundException

configure()

Configures the current command.

protected configure() : void

execute()

Executes the current command.

protected execute(InputInterface $input, OutputInterface $output) : int
Parameters
$input : InputInterface
$output : OutputInterface
Tags
throws
ExceptionInterface
see
setCode()
Return values
int

0 if everything went fine, or an exit code

On this page

Search results