doctrine-mongodb

How sort an array in a collection

痞子三分冷 提交于 2020-01-21 12:53:10
问题 I've been looking for sorting a specific inner array in a collection, I use doctrine-mongodb-bundle in symfony2. My collection : "page": { "_id": "56rgt46rt54h68rt4h6" "categories": [{ "_id": "2g56rt1h65rt165165erg4" "products":[ {"name":"A", "pos": 2}, {"name":"B", "pos": 7}, {"name":"C", "pos": 1}, {"name":"D", "pos": 5} ] }] } I wish I had : "page": { "_id": "56rgt46rt54h68rt4h6" "categories": [{ "_id": "2g56rt1h65rt165165erg4" "products":[ {"name":"C", "pos": 1}, {"name":"A", "pos": 2}, {

How to customize configureDatagridFilters in Sonata Admin to use non related mongodb documents

本小妞迷上赌 提交于 2020-01-06 02:41:05
问题 In my Mongodb I got a passenger document, this is a typical item: { "_id" : ObjectId("51efdf818d6b408449000002"), "createdAt" : 1374674817, "phone" : "222222", .. } I also have a device document that references a passenger document, here is an example: { "_id" : ObjectId("51efdf818d6b408449000001"), "os" : "android.gcm", "passenger" : ObjectId("51efdf818d6b408449000002"), .. } so in other words.. there is no way I can find out the device belonging to a passenger by running a query on

ClassNotFoundException: Attempted to load class “Mongo” from… (with persist) symfony2

橙三吉。 提交于 2019-12-23 09:32:27
问题 I am having some issue integrating mongodb with Symfony (version 2.5.0-DEV) using the doctrine mongodb cookbook on http://symfony.com/doc/current/bundles/DoctrineMongoDBBundle/index.html. Everything is okay up to the 'Persisting Objects to MongoDB' stage. When I add the line " $dm->persist($script); ", nothing happens to my remote database and I get the error message: ClassNotFoundException: Attempted to load class "Mongo" from the global namespace in /var/www/Symfony/vendor/doctrine/mongodb

Symfony2 Form pre-fill fields with data

眉间皱痕 提交于 2019-12-10 14:44:16
问题 Assume for a moment that this form utilizes an imaginary Animal document object class from a ZooCollection that has only two properties ("name" and "color") in symfony2. I'm looking for a working simple stupid solution , to pre-fill the form fields with the given object auto-magically (eg. for updates ?). Acme/DemoBundle/Controller/CustomController : public function updateAnimalAction(Request $request) { ... // Create the form and handle the request $form = $this->createForm(AnimalType(),

Mongodb Subdocument Date Range Returns Wrong Results

时间秒杀一切 提交于 2019-12-06 12:18:59
问题 first time in Stackoverflow. I'm trying to run a date range query on an array collection but Mongo Shell returning irrelevant documents witch doesn't match my criteria. It doesn't matter i'm doing the query trough PHP drivers, Doctrine Mongodb Query-builder or Mongo Shell. Here is my query: db.deals.find( { "total_sold.created_at": { $gt: new ISODate("2014-03-05T00:00:00Z"), $lt: new ISODate("2014-03-05T23:59:00Z") } }).limit(1).pretty() And here is the result: { "_id" :

Mongodb Subdocument Date Range Returns Wrong Results

我怕爱的太早我们不能终老 提交于 2019-12-04 19:45:33
first time in Stackoverflow. I'm trying to run a date range query on an array collection but Mongo Shell returning irrelevant documents witch doesn't match my criteria. It doesn't matter i'm doing the query trough PHP drivers, Doctrine Mongodb Query-builder or Mongo Shell. Here is my query: db.deals.find( { "total_sold.created_at": { $gt: new ISODate("2014-03-05T00:00:00Z"), $lt: new ISODate("2014-03-05T23:59:00Z") } }).limit(1).pretty() And here is the result: { "_id" : "1241412fb99a11a0bc70032a2cb6059b", "total_sold" : [ { "some_field": "value", "created_at" : ISODate("2014-02-13T15:48:35Z")

How sort an array in a collection

谁说我不能喝 提交于 2019-12-01 21:12:14
I've been looking for sorting a specific inner array in a collection, I use doctrine-mongodb-bundle in symfony2. My collection : "page": { "_id": "56rgt46rt54h68rt4h6" "categories": [{ "_id": "2g56rt1h65rt165165erg4" "products":[ {"name":"A", "pos": 2}, {"name":"B", "pos": 7}, {"name":"C", "pos": 1}, {"name":"D", "pos": 5} ] }] } I wish I had : "page": { "_id": "56rgt46rt54h68rt4h6" "categories": [{ "_id": "2g56rt1h65rt165165erg4" "products":[ {"name":"C", "pos": 1}, {"name":"A", "pos": 2}, {"name":"D", "pos": 5}, {"name":"B", "pos": 7} ] }] } And my entities : /** * @MongoDB\EmbeddedDocument