Skip to content

Commit

Permalink
Move Projection operators to a dedicated namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
GromNaN committed Oct 11, 2023
1 parent bdfbcc5 commit c7bc14c
Show file tree
Hide file tree
Showing 17 changed files with 144 additions and 84 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ psalm-baseline.xml export-ignore
# https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github
/src/Builder/Expression/*.php linguist-generated=true
/src/Builder/Query/*.php linguist-generated=true
/src/Builder/Projection/*.php linguist-generated=true
/src/Builder/Stage/*.php linguist-generated=true
11 changes: 11 additions & 0 deletions generator/config/definitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,15 @@
OperatorFactoryGenerator::class,
],
],

// Projection Operators
[
'configFiles' => __DIR__ . '/projection',
'namespace' => 'MongoDB\\Builder\\Projection',
'classNameSuffix' => 'Operator',
'generators' => [
OperatorClassGenerator::class,
OperatorFactoryGenerator::class,
],
],
];
2 changes: 1 addition & 1 deletion generator/config/expression/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ category:
- 'Text Expression Operator'
link: 'https://www.mongodb.com/docs/manual/reference/operator/aggregation/meta/'
type:
- resolvesToDecimal
- resolvesToAny
encode: single
description: |
Access available per-document metadata related to the aggregation operation.
Expand Down
15 changes: 15 additions & 0 deletions generator/config/projection/elemMatch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# $schema: ../schema.json
name: $elemMatch
category:
- 'Projection Operators'
link: 'https://www.mongodb.com/docs/manual/reference/operator/projection/elemMatch/'
type:
- projection
encode: object
description: |
Projects the first element in an array that matches the specified $elemMatch condition.
arguments:
-
name: query
type:
- query
File renamed without changes.
7 changes: 3 additions & 4 deletions generator/config/query/elemMatch.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
# $schema: ../schema.json
name: $elemMatch
category:
- 'Projection Operators'
- 'Array Query Operators'
link: 'https://www.mongodb.com/docs/manual/reference/operator/query/elemMatch/'
type:
- filter
- projection
encode: object
description: |
Projects the first element in an array that matches the specified $elemMatch condition.
The $elemMatch operator matches documents that contain an array field with at least one element that matches all the specified query criteria.
arguments:
-
name: queries
name: query
type:
- query
10 changes: 0 additions & 10 deletions generator/config/query/meta.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<file>rector.php</file>

<!-- Ignore auto-generated code -->
<exclude-pattern>src/Builder/(Expression|Query|Stage)/*\.php</exclude-pattern>
<exclude-pattern>src/Builder/(Expression|Query|Projection|Stage)/*\.php</exclude-pattern>

<!-- Target minimum supported PHP version -->
<config name="php_version" value="70400"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Builder/Expression/MetaOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/Builder/Projection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace MongoDB\Builder;

use MongoDB\Builder\Projection\FactoryTrait;

enum Projection
{
use FactoryTrait;
}
44 changes: 44 additions & 0 deletions src/Builder/Projection/ElemMatchOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions src/Builder/Projection/FactoryTrait.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 9 additions & 10 deletions src/Builder/Query/ElemMatchOperator.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 4 additions & 26 deletions src/Builder/Query/FactoryTrait.php

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 0 additions & 25 deletions src/Builder/Query/MetaOperator.php

This file was deleted.

7 changes: 2 additions & 5 deletions src/Builder/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ result types would be rejected.
We rely on the server will reject the query if the expression is not of the expected type.


# Query & Filter
## Query & Filter

The `query` are used in a `$match`, `$geoNear` or `$graphLookup` stages and `$elemMatch` operator.
The `filter` are used compose query. A query is a map of field name to filter and/or a list of other queries.
Expand Down Expand Up @@ -127,10 +127,7 @@ Stage::match(Query::query(...));

# Projection





Projection operators have a dedicated namespace and interface.

# Specificities

Expand Down

0 comments on commit c7bc14c

Please sign in to comment.