Created
December 9, 2020 05:59
-
-
Save deepakaryan1988/656bf479d0f9561cb79b2588845176ff to your computer and use it in GitHub Desktop.
Deletemany mongodb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$collection = 'post'; | |
$uid = '482'; | |
$database = \Drupal::service('mongodb.database_factory')->get('default'); | |
$collection = $database->selectCollection($collection); | |
$selector = ['user_id.target_id' => (int) $uid]; | |
$deleteResult = $collection->deleteMany($selector); | |
kint($deleteResult->getDeletedCount()); | |
kint($deleteResult);exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment