Category : mongodb

I have a collection that I would like to restrict duplicates of documents with specific fields. Following guidance at this SO thread, I have manually implemented an index: { "playerName": 1, "comp.compName": 1, "comp.roundNo": 1 }, { "unique": true } Now when I try to insert a new document that would cause a duplicate, the ..

Read more

I managed to install mongoDB with php8.0 on an apache2 server but I’m unable to it.<?php phpinfo(); ?> shows me that mongoDB 1.9.1 is enabled and everything should be working but when I use $mongo = new MongoDBDriverManager("mongodb://127.0.0.1:27017"); I’ll get the following error: PHP Fatal error: Uncaught Error: Call to undefined method MongoDBDriverManager::selectDB() in / ..

Read more

I want to parse this MongoDB error message. I can’t manage to access the variables in the object. I assume I overlook something trivial, but I can’t figure it out. The var_dump var_dump($error); object(MongoDBDriverWriteError)#11 (4) { ["message"]=> string(362) "E11000 duplicate key error collection: database.collection index: c_address collation: { locale: "nl", caseLevel: false, caseFirst: "off", strength: ..

Read more

I have following collection called config_settings in my mongo db /** * @MongoDBDocument(collection="config_settings", repositoryClass="AppBundleRepositorySettingRepository") * @MongoDBHasLifecycleCallbacks() */ class Setting { /** * @MongoDBId() * @var ObjectId $id */ protected $id; /** * @MongoDBField(type="string") * @var string $name */ protected $name; /** * @MongoDBField(type="raw") * @var array<array> $value */ protected $value; /** * @return mixed */ ..

Read more