Skip to content

Commit

Permalink
Update README to 5.4 array syntax.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Stipak committed May 5, 2015
1 parent 5e45db6 commit 9838c62
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ $collection->drop();
$collection->truncate();

// Insert some values into the collection
$insertIds = $collection->insert(array(
array(
$insertIds = $collection->insert([
[
'name' => 'John',
'surname' => 'Doe',
'nick' => 'The Unknown Man',
'age' => 20,
),
array(
],
[
'name' => 'Frank',
'surname' => 'de Jonge',
'nick' => 'Unknown',
'nik' => 'No Man',
'age' => 23,
),
));
],
]);

// Update a collection
$collection->update(function ($query) {
Expand All @@ -85,7 +85,10 @@ $frank = $collection->findOne(function ($query) {
});

// Or find him using normal array syntax
$frank = $collection->find(array('name' => 'Frank', 'surname' => new MongoRegex('/e Jo/imxsu')));
$frank = $collection->find([
'name' => 'Frank',
'surname' => new MongoRegex('/e Jo/imxsu')
]);

$frank['age']++;

Expand All @@ -112,19 +115,19 @@ A big part of the newly released MongoDB pecl package is aggregation support. Wh

```php
$collection->aggregate(function ($a) {
$a->project(array(
$a->project([
'name' => 1,
'surname' => -1,
'tags' => 1,
))->unwind('tags');
])->unwind('tags');

// But also more advanced groups/projections
$a->project(function ($p) {
$p->select('field')
->select('scores')
->exclude('other_field');
})->group(function ($g) {
$g->by(array('$name', '$surname'))
$g->by(['$name', '$surname'])
->sum('scores');
});
});
Expand Down

0 comments on commit 9838c62

Please sign in to comment.