Skip to content

Commit b210322

Browse files
authored
Document execute options (#918)
1 parent 38278bd commit b210322

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

core/mongodb.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,67 @@ See how to use them and how to create custom ones in the [filters documentation]
214214
## Creating Custom Extensions
215215

216216
See how to create Doctrine MongoDB ODM custom extensions in the [extensions documentation](extensions.md).
217+
218+
## Adding Execute Options
219+
220+
If you want to add some command options when executing an aggregate query (see the [related documentation in MongoDB manual](https://docs.mongodb.com/manual/reference/command/aggregate/#command-fields)),
221+
you can do it in your resource configuration, at the operation or the resource level.
222+
223+
For instance at the operation level:
224+
225+
```php
226+
<?php
227+
// api/src/Document/Offer.php
228+
229+
namespace App\Document;
230+
231+
use ApiPlatform\Core\Annotation\ApiResource;
232+
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
233+
234+
/**
235+
* @ApiResource(attributes={
236+
* collectionOperations={
237+
* "get"={
238+
* "method"="GET",
239+
* "doctrine_mongodb"={
240+
* "execute_options"={
241+
* "allowDiskUse"=true
242+
* }
243+
* }
244+
* }
245+
* }
246+
* })
247+
* @ODM\Document
248+
*/
249+
class Offer
250+
{
251+
// ...
252+
}
253+
```
254+
255+
Or at the resource level:
256+
257+
```php
258+
<?php
259+
// api/src/Document/Offer.php
260+
261+
namespace App\Document;
262+
263+
use ApiPlatform\Core\Annotation\ApiResource;
264+
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
265+
266+
/**
267+
* @ApiResource(attributes={
268+
* "doctrine_mongodb"={
269+
* "execute_options"={
270+
* "allowDiskUse"=true
271+
* }
272+
* }
273+
* })
274+
* @ODM\Document
275+
*/
276+
class Offer
277+
{
278+
// ...
279+
}
280+
```

0 commit comments

Comments
 (0)