Skip to content

Tag: mongodb

How to get mongodb collection iterator?

I’m connecting to mongo db like this: Getting collection like this: And getting collection iterator like this: However last call shoots error: [error] Could not retrieve source count from demo_article: Authentication failed. What I’m doing wrong here? UPDATE: Here: iterator is Traversable. But the…

How to get object id from array using php mongod

I have a array $document after query findOne() I want get 60d2f531a5476f4eb220402b by use $document[‘_id’]->__toString(); but it never work Answer The stdClass object does not have any methods by default, so you address the $id field like this

PHP updating multiple elements of sub-array of MongoDB document

I have the following document structure. I am trying to update specific values inside the holes sub-array: Each holes Array element is an Object representing the score on a golf hole, with various properties (fields). I am trying to provide the ability to update the holeGross field ONLY for each score. On my …

Insert a Json object in MongoDB from Laravel 7

I need upload a image to Google storage and insert the below JSON object with the gcs image path in MongoDB. The image is successfully getting uploaded in GCS, but I am not able to get the image url of the image and also not able to update the path in mongoDB. JSON object format Can anyone help me to