Questions tagged [doctrine-odm]

Doctrine Object Document Mapper is built for PHP 5.3.2+ and provides transparent persistence between PHP objects and data stores such as MongoDB, CouchDB, OrientDB, and PHPCR.

Doctrine Object Document Mapper is built for PHP 5.3.2+ and provides transparent persistence between PHP objects and data stores such as MongoDB, CouchDB, OrientDB, and PHPCR.

Related links

538 questions
2
votes
1 answer

ODM inheritance document with type SINGLE_COLLECTION schema create error

I have inheritance document with type SINGLE_COLLECTION configured in my Symfony 4.4 app. When i run command bin/console doctrine:mongodb:schema:create, then error occurs a collection 'db.Person' already exists. Everything was done according to the…
Mateusz K.
  • 111
  • 6
2
votes
1 answer

Doctrine ODM / MongoDB : in AND in queries

I'm using Doctrine ODM with mongoDB. I'm trying to do queries like : $queryBuilder->field('array_field')->in('even_value_1', 'event_value_2'); $queryBuilder->field('array_field')->in('odd_value_1', 'odd_value_2'); The idea is to select all…
Gérald Croës
  • 3,799
  • 2
  • 18
  • 20
2
votes
2 answers

Doctrine ODM - float field not working with decimal field

I have a document in doctrine with the field config set to /** @ODM\Field(type="float") */ public $stock_price; and on my mongodb the field has a validation for decimal stock_price: { bsonType: 'decimal', description: 'must be a decimal…
2
votes
1 answer

What is discriminator field conflict in PHP Doctrine MongoDB ODM?

What does it mean when error Discriminator field "x" in "y" conflicts with a mapped field's "name" attribute. is thrown? More specifically I mean this condition: if ($this->discriminatorField !== null && $this->discriminatorField ===…
Luka Žitnik
  • 1,160
  • 8
  • 15
2
votes
1 answer

Doctrine ODM Save JSON Object without mapping every single key

I am aware that ODM purpose is mapping, but I'm also curious if I can save a JSON Object without mapping it to any class. Or with mapping it to a class but having only one object value $object. I've managed to do this when ever I would have an…
Dino
  • 7,779
  • 12
  • 46
  • 85
2
votes
1 answer

Attempted to load class "ObjectID" from namespace "MongoDB\BSON"

I'm trying to use DoctrineMongoDBBundle but it gives me this error : Attempted to load class "ObjectID" from namespace "MongoDB\BSON". Did you forget a "use" statement for another namespace? I've searched all over for a reason, but I could not…
user8958506
2
votes
2 answers

Symfony 3.3 + Doctrine/MongoDB: Register custom mapping type

Since Symfony 3.3 the file app/autoload.php disappeared. But I used it to register a custom mapping type as described here. My current app/autoload.php looks like this: use Doctrine\Common\Annotations\AnnotationRegistry; use…
Spunc
  • 338
  • 1
  • 14
2
votes
1 answer

Doctrine ODM: get array of specific fields

So, the problem is to get ids (or any another fields) in one array, like: [ "someId1", "someId2", "someId3", ] I tried to take it by next query: $this->createQueryBuilder() ->select('_id') ->hydrate(false) …
2
votes
1 answer

Reference ORM (Entity) from ODM (Document, MongoDB) with ManyToMany relationship

I am trying to blend ODM (MongoDB) and ORM in my Symfony 2.6 with a reference to the Documentation "Blending ORM and MongoDB ODM" I have two entities, User and Category. Also I have one Document Product. It's clear when blending ODM and ORM, it can…
Ilia Shakitko
  • 1,417
  • 2
  • 18
  • 25
2
votes
1 answer

How to "group by" field "count" in mongodb querybuilder?

I want to classify cities with the products they have. I have two documents: Product and city. The product has its ID and a reference to a city document: Product(id) City P1 ------------ Atlanta P2 ------------ New York …
Matheus Oliveira
  • 587
  • 3
  • 10
  • 33
2
votes
1 answer

Mongodb limit result number with something like groupby

I have a MongoDB collection with multiple hierarchy, for the example I will use a collection with countries, that contain cities, each document is for a particular city and contain the population value for the country and the city (country_pop and…
iBadGamer
  • 566
  • 6
  • 22
2
votes
1 answer

Is it possible to use two diffrent document managers with different databases for the same bundle in Symfony?

My goal is to have two different document managers connected to different databases that share the same database models. I have heavily changed my database model and I would like to write a custom migration script that retrieves objects from the…
matyas
  • 2,696
  • 23
  • 29
2
votes
0 answers

Doctrine Mongo ODM relations using fields that are not _id

I'm having trouble mapping relations in Doctrine ODM, because they're not using the _id field. I'm currently building a symfony app using the Doctrine Mongo ODM. The app is being built on top of a legacy Mongo schema (the database is already in…
applestump
  • 21
  • 1
2
votes
1 answer

JMSSerializerBundle and Symfony 2 - Output Doctrine/ODM to JSON file

I am trying to retrieve all records and display them in a JSON file. My current function retrieves all Events that belong to a specific user. /** * create json files from doctrine/mongo * @Route("/createjson", name="createjson") */ public…
Brendan
  • 908
  • 2
  • 15
  • 30
2
votes
1 answer

FindBy('myvar' => $array) not working with mongoDbOdm in Symfony3?

I have filled a mongodb-collection with the following values (identifer = myvar): array (size=10) 0 => string 'B00LHILHS8' (length=10) 1 => string 'B00WSCCMV8' (length=10) 2 => string 'B00MA15OK8' (length=10) However - findBy(['myvar' =>…
Roman
  • 2,530
  • 2
  • 27
  • 50