mongo

MongoDB - help with a PHP query

Hi guys, I have the following object stored in a MongoDB: [_id] => MongoId Object ( ) [horses] => Array ( [0] => Array ( [name] => Youve Been Mowed [selectionId] => 3004097 ) [1] => Array ( [name] => Rascal In The Mix [selectionId] => 3460932 ) [2] => Array ( [name] => Clumber...

Querying Data Type of a Field in MongoDB

In MongoDB, using $type, it is possible to filter a search based on if the field matches a BSON data type (see DOCS). For eg. > db.posts.find({date2: {$type: 9}}, {date2: 1}) { "_id" : ObjectId("4c0ec11e8fd2e65c0b010000"), "date2" : "Fri Jul 09 2010 08:25 :26 GMT" } I need a query that will tell me what the actual type of the field i...

How to get sorted results in MongoKit?

How can I perform query like: db.articles.find().sort({created_at: -1}).limit(5); in MongoKit driver? Perhaps I'm blind, but I can't find it in manual. I want to retrieve 5 last products ordered by 'created_at'. MongoKit offers to sort result list (it's more then 2000 items) and slice it. It's unaccepable, I want to sort() and limit() o...

Doctrine schema - avoid sql generation for specific table

Hello everyone, i'm kinda new to Doctrine, been using Porpel before.. I'd like to generate model classes from my schema, but the objects will be stored in a mongoDB - thus i don't need/want Doctrine to generate and insert the SQL for those tables. In Propel there was a handy attribute (skipSql: true) which worked like a charm for ...

Mongo one to many relation and update problems

Hi guys, I'm implementing blog based on MongoDB. Let's look at first how Mongo guys recommend us to store blog post and its comments (http://www.mongodb.org/display/DOCS/Schema+Design): posts should be a collection. comments should be embedded objects within a post for performance. I found that it is very difficult to edit or just ...

Storing Embedded Comments vs. Avoiding overhead in MongoDB

Hey Everyone, Let me explain my problem, and hopefully someone can offer some good advice. I am currently working on a web-app that stores information and meta-data for a large amount of applications. For each application there could be anywhere from 10 to 100's of comments that are tied to the application and an application version i...

mongoDB map/reduce minus the reduce

I have some 25k documents (4 GB in raw json) of data that I want to perform a few javascript operations on to make it more accessible to my end data consumer (R), and I would like to sort of "version control" these changes by adding a new collection for each change, but I cannot figure out how to map/reduce without the reduce. I want a o...

Working with hierarchical data in Mongo.

Note: I ended up answering my own question shortly after posting this. Thanks and sorry if you spent time reading my rediculously long post. Introduction I'm sort of a Mongo noob, just trying to get the hang of things here. I am looking at trying to create a hierarchical data structure to which i can add nodes/leaves dynamically. ...

MongoDB backup plan

I want to switch from MySQL to MongoDB but great data losses (more than 1 hour) are not acceptable for me. I need to have 3 backup plans: Hourly backup plan. Data is flushed to disk every X minutes and if something wrong with the server I shall be sure that after reboot it will have all data at least for an hour ago. Can I configure i...

Creating indexes on new collections in MongoDB + PHP

We use MongoDB to collect logs on pageviews. $collection_name = "logs.".date('Y').".".date('m').".".date('d'); $collection = $this->Mongo->$collection_name; $collection->insert($pageview); The code above creates a new collection for every day. I would like to be able to create an index on the above collection when it is created. Is...

MongoDB and Java Objects

Hi, I have the following MongoDB object stored in my Mongo database: array ( '_id' => new MongoId("4cc183de48aa4c7708000000"), 'vehicleMake' => 'Volkswagen', 'vehicleModel' => 'Carrier', 'vehicleNumPassengers' => '7', 'vehicleReg' => '07-D-748393', 'coords' => array ( 0 => array ( 'lat' => '53.2594946', ...

How come when I push "up" on MongoDB's console, it doesn't cycle through my previous command?

Instead, it displays this: ^[[A^[[A ...

How come a document in MongoDB sometimes gets inserted , but most often don't?

con = pymongo.Connection('localhost',27017) db = con.MouseDB post = { ...some stuff } datasets = db.datasets datasets.insert(post) So far, there are only 3 records, and it's supposed to have about 100... ...

When I do Geospatial querying in MongoDB, how do I also return the distance from my desired point?

for post in db.datasets.find({"loc":{"$near":[50,50]}}).limit(10): How do I get the distance between the document and "50,50"? ...

How do you query this in Mongo? (is not null)

db.mycollection.find(HAS IMAGE URL) ...