FAQ Database Discussion Community


Sorting a collection in doctrine2

php,mongodb,doctrine2,doctrine,odm
I've written the following query (that may or may not be efficient, I'm still a newbie): $collection = $this->dm->getConnection()->selectCollection('db_name', 'collection_name'); $query = array('array_name' => new \MongoId(id)); $cursor = $collection->find($query)->limit(9)->sort('r', 'desc'); I'm trying to sort by an r value that looks like this in the document: "r": 0.58325652219355106354 but it isn't...

Doctrine-ODM (MongoDB) - FindByMultipleIDs

php,mongodb,doctrine,odm
I am using Doctrine ODM(MongoDB). I am trying to write doctrine odm query builder to get the data where IDs IN (1,2,3). But i am not able to get it. Please help me on this. I want to create odm query builder for the normal sql query like below, SELECT...

MongoDB - Query conundrum - Document refs or subdocument

javascript,node.js,mongodb,mongoose,odm
I've run into a bit of an issue with some data that I'm storing in my MongoDB (Note: I'm using mongoose as an ODM). I have two schemas: mongoose.model('Buyer',{ credit: Number, }) and mongoose.model('Item',{ bid: Number, location: { type: [Number], index: '2d' } }) Buyer/Item will have a parent/child association,...