1 | <?php |
||
33 | trait MongoIndexHelper |
||
34 | { |
||
35 | use MongoHelper; |
||
36 | |||
37 | /** |
||
38 | * Creates some indexes in a collection. |
||
39 | * |
||
40 | * @param $manager - The MongoDB manager |
||
41 | * @param $db - The database name |
||
42 | * @param $collection - The collection name |
||
43 | * @param array<MongoIndex> The indexes to create |
||
44 | * @return array<string> The names of the created indexes |
||
45 | * @see https://docs.mongodb.com/manual/reference/command/createIndexes/ |
||
46 | * @throws \Caridea\Dao\Exception\Unreachable If the connection fails |
||
47 | * @throws \Caridea\Dao\Exception\Unretrievable If the document doesn't exist |
||
48 | * @throws \Caridea\Dao\Exception\Violating If a constraint is violated |
||
49 | * @throws \Caridea\Dao\Exception\Inoperable If an API is used incorrectly |
||
50 | * @throws \Caridea\Dao\Exception\Generic If any other database problem occurs |
||
51 | */ |
||
52 | protected function createIndexes(\MongoDB\Driver\Manager $manager, string $db, string $collection, array $indexes): array |
||
68 | |||
69 | /** |
||
70 | * Deletes some indexes in a collection. |
||
71 | * |
||
72 | * This method will first check for the existence of the supplied indexes |
||
73 | * and if found, will drop them. |
||
74 | * |
||
75 | * @param $manager - The MongoDB manager |
||
76 | * @param $db - The database name |
||
77 | * @param $collection - The collection name |
||
78 | * @param array<string> $names The indexes to delete |
||
79 | * @return array<string> The names of the created indexes |
||
80 | * @see https://docs.mongodb.com/manual/reference/command/dropIndexes/ |
||
81 | * @throws \Caridea\Dao\Exception\Unreachable If the connection fails |
||
82 | * @throws \Caridea\Dao\Exception\Unretrievable If the document doesn't exist |
||
83 | * @throws \Caridea\Dao\Exception\Violating If a constraint is violated |
||
84 | * @throws \Caridea\Dao\Exception\Inoperable If an API is used incorrectly |
||
85 | * @throws \Caridea\Dao\Exception\Generic If any other database problem occurs |
||
86 | */ |
||
87 | protected function dropIndexes(\MongoDB\Driver\Manager $manager, string $db, string $collection, array $names): array |
||
110 | } |
||
111 |