Error: Call to undefined method MongoDB\Model\CollectionInfo::insertOne()

Created on 9 October 2023, about 1 year ago
Updated 25 October 2023, about 1 year ago

when i uploading a file to mongo db getting error.Error: Call to undefined method MongoDB\Model\CollectionInfo::insertOne() in Drupal\eri_mongo\Form\EriMongoForm->submitForm()

error line is this. $collection->insertOne($data);

💬 Support request
Status

Fixed

Version

2.0

Component

Base module (driver)

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Remya.P
  • Status changed to Postponed: needs info about 1 year ago
  • 🇫🇷France fgm Paris, France

    The namespace eri_mongo does not belong to this module. Is this your custom code ? Or are you using some specific third-party package ? I can not find eri_mongo on drupal.org.

  • 🇫🇷France fgm Paris, France

    Without an answer from you, I can only hazard three hypotheses, in order of decreasing likelihood.

    • The code in the eri_mongo has a bug, trying to insert documents in a collection info instead of a collection.
    • The site uses that eri_mongo module, was not installed with Composer and the non-Composer install missed installing the MongoDB PHP library (that missing class is from the MongoDB PHP library, not the MongoDB module suite
    • That eri_mongo module is missing the declaration of the dependency on the MongoDB PHP library, or even missing a composer.json altogether

    Note that all three may actually be present.

    Since none of these seem to be related to the MongoDB module suite, I shall be closing this issue unless you provide more information.

  • actually eri_mongo is the custom module.

  • 🇫🇷France fgm Paris, France

    OK, so the issue is in that module: the bug is that the code at that line is trying to use insertOne on the wrong object: it is using the CollectionInfo instead of the Collection.

    You can look at the way to insert documents in mongodb/modules/mongodb_storage/src/Queue/Queue.php::createItem();.

  • Status changed to Fixed about 1 year ago
  • 🇫🇷France fgm Paris, France

    No answer over 1 week later, assuming fixed. Feel free to reopen if you need more help.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024