See Release Notes
Long Term Support Release
Differences Between: [Versions 311 and 401] [Versions 400 and 401]
1 <?php 2 /* 3 * Copyright 2020-present MongoDB, Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * https://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 namespace MongoDB\Operation; 19 20 use Iterator; 21 use MongoDB\Command\ListCollections as ListCollectionsCommand; 22 use MongoDB\Driver\Exception\RuntimeException as DriverRuntimeException; 23 use MongoDB\Driver\Server; 24 use MongoDB\Exception\InvalidArgumentException; 25 use MongoDB\Model\CallbackIterator; 26 27 /** 28 * Operation for the listCollectionNames helper. 29 * 30 * @api 31 * @see \MongoDB\Database::listCollectionNames() 32 * @see https://mongodb.com/docs/manual/reference/command/listCollections/ 33 */ 34 class ListCollectionNames implements Executable 35 { 36 /** @var ListCollectionsCommand */ 37 private $listCollections; 38 39 /** 40 * Constructs a listCollections command. 41 * 42 * Supported options: 43 * 44 * * authorizedCollections (boolean): Determines which collections are 45 * returned based on the user privileges. 46 * 47 * For servers < 4.0, this option is ignored. 48 * 49 * * comment (mixed): BSON value to attach as a comment to this command. 50 * 51 * This is not supported for servers versions < 4.4. 52 * 53 * * filter (document): Query by which to filter collections. 54 * 55 * * maxTimeMS (integer): The maximum amount of time to allow the query to 56 * run. 57 * 58 * * session (MongoDB\Driver\Session): Client session. 59 * 60 * @param string $databaseName Database name 61 * @param array $options Command options 62 * @throws InvalidArgumentException for parameter/option parsing errors 63 */ 64 public function __construct(string $databaseName, array $options = []) 65 { 66 $this->listCollections = new ListCollectionsCommand($databaseName, ['nameOnly' => true] + $options); 67 } 68 69 /** 70 * Execute the operation. 71 * 72 * @see Executable::execute() 73 * @return Iterator 74 * @throws DriverRuntimeException for other driver errors (e.g. connection errors) 75 */ 76 public function execute(Server $server): Iterator 77 { 78 return new CallbackIterator( 79 $this->listCollections->execute($server), 80 function (array $collectionInfo) { 81 return $collectionInfo['name']; 82 } 83 ); 84 } 85 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body