Skip to content

Instantly share code, notes, and snippets.

@deepakaryan1988
Created December 9, 2020 05:59
Show Gist options
  • Save deepakaryan1988/656bf479d0f9561cb79b2588845176ff to your computer and use it in GitHub Desktop.
Save deepakaryan1988/656bf479d0f9561cb79b2588845176ff to your computer and use it in GitHub Desktop.
Deletemany mongodb
$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