5
5
use MongoDB \Driver \ReadConcern ;
6
6
use MongoDB \Driver \ReadPreference ;
7
7
use MongoDB \Driver \WriteConcern ;
8
- use Tequila \MongoDB \OptionsResolver \Command \AggregateResolver ;
9
- use Tequila \MongoDB \OptionsResolver \Command \CountResolver ;
10
- use Tequila \MongoDB \OptionsResolver \Command \CreateIndexesResolver ;
11
- use Tequila \MongoDB \OptionsResolver \Command \DistinctResolver ;
12
- use Tequila \MongoDB \OptionsResolver \Command \DropCollectionResolver ;
13
- use Tequila \MongoDB \OptionsResolver \Command \DropIndexesResolver ;
14
- use Tequila \MongoDB \OptionsResolver \Command \FindAndModifyResolver ;
15
8
use Tequila \MongoDB \OptionsResolver \Command \FindOneAndDeleteResolver ;
16
9
use Tequila \MongoDB \OptionsResolver \Command \FindOneAndUpdateResolver ;
17
10
use Tequila \MongoDB \Exception \InvalidArgumentException ;
18
11
use Tequila \MongoDB \Exception \UnexpectedResultException ;
19
12
use Tequila \MongoDB \OptionsResolver \BulkWrite \BulkWriteResolver ;
20
13
use Tequila \MongoDB \OptionsResolver \DatabaseOptionsResolver ;
14
+ use Tequila \MongoDB \OptionsResolver \OptionsResolver ;
21
15
use Tequila \MongoDB \OptionsResolver \QueryOptionsResolver ;
22
- use Tequila \MongoDB \OptionsResolver \ResolverFactory ;
23
- use Tequila \MongoDB \Traits \CommandBuilderTrait ;
16
+ use Tequila \MongoDB \Traits \CommandExecutorTrait ;
24
17
use Tequila \MongoDB \Traits \ExecuteCommandTrait ;
25
18
use Tequila \MongoDB \Write \Model \DeleteMany ;
26
19
use Tequila \MongoDB \Write \Model \DeleteOne ;
36
29
37
30
class Collection
38
31
{
39
- use CommandBuilderTrait ;
32
+ use CommandExecutorTrait ;
40
33
use ExecuteCommandTrait;
41
34
42
35
/**
@@ -87,7 +80,7 @@ public function __construct(ManagerInterface $manager, $databaseName, $collectio
87
80
'writeConcern ' => $ this ->manager ->getWriteConcern (),
88
81
];
89
82
90
- $ options = ResolverFactory ::get (DatabaseOptionsResolver::class)->resolve ($ options );
83
+ $ options = OptionsResolver ::get (DatabaseOptionsResolver::class)->resolve ($ options );
91
84
$ this ->readConcern = $ options ['readConcern ' ];
92
85
$ this ->readPreference = $ options ['readPreference ' ];
93
86
$ this ->writeConcern = $ options ['writeConcern ' ];
@@ -106,8 +99,7 @@ public function aggregate(array $pipeline, array $options = [])
106
99
107
100
return $ this ->executeCommand (
108
101
['aggregate ' => $ this ->collectionName ],
109
- ['pipeline ' => $ pipeline ] + $ options ,
110
- AggregateResolver::class
102
+ ['pipeline ' => $ pipeline ] + $ options
111
103
);
112
104
}
113
105
@@ -150,8 +142,7 @@ public function count(array $filter = [], array $options = [])
150
142
{
151
143
$ cursor = $ this ->executeCommand (
152
144
['count ' => $ this ->collectionName , 'query ' => (object )$ filter ],
153
- $ options ,
154
- CountResolver::class
145
+ $ options
155
146
);
156
147
157
148
$ result = $ cursor ->current ();
@@ -191,8 +182,7 @@ public function createIndexes(array $indexes, array $options = [])
191
182
192
183
$ this ->executeCommand (
193
184
['createIndexes ' => $ this ->collectionName , 'indexes ' => $ compiledIndexes ],
194
- $ options ,
195
- CreateIndexesResolver::class
185
+ $ options
196
186
);
197
187
198
188
return array_map (function (Index $ index ) {
@@ -251,8 +241,7 @@ public function distinct($fieldName, array $filter = [], array $options = [])
251
241
252
242
$ cursor = $ this ->executeCommand (
253
243
$ command ,
254
- $ options ,
255
- DistinctResolver::class
244
+ $ options
256
245
);
257
246
258
247
$ result = $ cursor ->current ();
@@ -273,8 +262,7 @@ public function drop(array $options = [])
273
262
{
274
263
$ cursor = $ this ->executeCommand (
275
264
['drop ' => $ this ->collectionName ],
276
- $ options ,
277
- DropCollectionResolver::class
265
+ $ options
278
266
);
279
267
280
268
return $ cursor ->current ();
@@ -290,7 +278,7 @@ public function dropIndexes(array $options = [])
290
278
'dropIndexes ' => $ this ->collectionName ,
291
279
'index ' => '* ' ,
292
280
];
293
- $ cursor = $ this ->executeCommand ($ command , $ options, DropIndexesResolver::class );
281
+ $ cursor = $ this ->executeCommand ($ command , $ options );
294
282
295
283
return $ cursor ->current ();
296
284
}
@@ -307,7 +295,7 @@ public function dropIndex($indexName, array $options = [])
307
295
'index ' => $ indexName ,
308
296
];
309
297
310
- $ cursor = $ this ->executeCommand ($ command , $ options, DropIndexesResolver::class );
298
+ $ cursor = $ this ->executeCommand ($ command , $ options );
311
299
312
300
return $ cursor ->current ();
313
301
}
@@ -319,7 +307,7 @@ public function dropIndex($indexName, array $options = [])
319
307
*/
320
308
public function find (array $ filter = [], array $ options = [])
321
309
{
322
- $ options = ResolverFactory ::get (QueryOptionsResolver::class)->resolve ($ options );
310
+ $ options = OptionsResolver ::get (QueryOptionsResolver::class)->resolve ($ options );
323
311
324
312
if (isset ($ options ['readPreference ' ])) {
325
313
$ readPreference = $ options ['readPreference ' ];
@@ -350,9 +338,9 @@ public function findOneAndDelete(array $filter, array $options = [])
350
338
'query ' => (object )$ filter ,
351
339
];
352
340
353
- $ options = ['remove ' => true ] + ResolverFactory ::get (FindOneAndDeleteResolver::class)->resolve ($ options );
341
+ $ options = ['remove ' => true ] + OptionsResolver ::get (FindOneAndDeleteResolver::class)->resolve ($ options );
354
342
355
- return $ this ->executeCommand ($ command , $ options, FindAndModifyResolver::class );
343
+ return $ this ->executeCommand ($ command , $ options );
356
344
}
357
345
358
346
/**
@@ -396,10 +384,10 @@ public function findOneAndUpdate(array $filter, $update, array $options = [])
396
384
'query ' => (object )$ filter ,
397
385
];
398
386
399
- $ options = ResolverFactory ::get (FindOneAndUpdateResolver::class)->resolve ($ options );
387
+ $ options = OptionsResolver ::get (FindOneAndUpdateResolver::class)->resolve ($ options );
400
388
$ options = ['update ' => (object )$ update ] + $ options ;
401
389
402
- return $ this ->executeCommand ($ command , $ options, FindAndModifyResolver::class );
390
+ return $ this ->executeCommand ($ command , $ options );
403
391
}
404
392
405
393
/**
@@ -526,7 +514,7 @@ public function updateOne($filter, $update, array $options = [])
526
514
*/
527
515
private static function extractBulkWriteOptions (array $ options )
528
516
{
529
- $ definedOptions = ResolverFactory ::get (BulkWriteResolver::class)->getDefinedOptions ();
517
+ $ definedOptions = OptionsResolver ::get (BulkWriteResolver::class)->getDefinedOptions ();
530
518
array_push ($ definedOptions , 'writeConcern ' );
531
519
532
520
$ bulkWriteOptions = array_intersect_key ($ options , array_flip ($ definedOptions ));
0 commit comments