public function KeyValueStore::has in MongoDB 8.2
Returns whether a given key exists in the store.
Parameters
string $key: The key to check.
Return value
bool TRUE if the key exists, FALSE otherwise.
Overrides KeyValueStoreInterface::has
File
- modules/
mongodb_storage/ src/ KeyValueStore.php, line 157
Class
- KeyValueStore
- Class KeyValueStore provides a KeyValueStore as a MongoDB collection.
Namespace
Drupal\mongodb_storageCode
public function has($key) {
$selector = [
'_id' => $this
->stringifyKey($key),
];
$doc = $this->mongoDbCollection
->findOne($selector, static::PROJECTION_ID);
$res = isset($doc);
return $res;
}