MongoDB\BSON\Iterator::key
PHP function
Edit on GitHub ✎
(mongodb >=1.16.0)
Returns the key of the current element
Description
MongoDB\BSON\Iterator::key(): string|int
Parameters Parameters
Return Values
Returns the key of the current element. When iterating a BSON document, the key will always be a string. When iterating a BSON array, the key will be an int.
Errors/Exceptions
- Throws
MongoDB\Driver\Exception\LogicExceptionif the iterator is not valid.
See Also
Iterator::key