mongodb

Connect to MongoDB sub-path

I'm trying to set up mongodb on webfaction. It works fine, currently running on port 36505 on the server. I can connect to it on the server just fine. But per the firewall, I can't connect to 36505 on the server from the 'net. I can expose the port by mapping the port to port 80 under a sub-path. So I can make 1.1.1.1:36505 to 1.1.1.1:8...

How do you print JSON from the mongdb ruby driver?

When I do a find query from the mongodb JavaScript console, I get a beautiful JSON response. However, when I do a find with the ruby driver, it stores the JSON as some Ruby object. How do I convert this back to JSON? Or, better yet, how do I just get the JSON without doing the extra conversions? ...

Pros and cons of external database services (mongohq, etc.)

For putting together a site from scratch, what are the advantages and disadvantages of using external database services, e.g. MongoHQ, Amazon RDS? ...

Recommended database backend for blog

Greetings, I'm building my personal website using php. My standard approach is to use MySQL as a database backend. I've been hearing a lot about document orienting databases and I'm wondering if these ( couchDB, mongoDB) might be a better option for me. I understand that a low traffic site such as my personal homepage isn't going to se...

Relationships and data modeling in document oriented databases

I just read a few articles on data modeling and relationships in document oriented databases (... anti pattern, CouchDB article, MongoDB article ...). There are certain "issues" about which I would like to talk and hopefully find a solution/pattern to stop them deluding me. There is a common saying that you should stop thinking like you...

mongodb gridfs carrierwave or joint or other ?

i want to store all my assets in mongo gridfs. i was trying to get carrierwave setup with mongomapper and gridfs but seems carrierwave supports mongoid now instead. I need to be able to save different size versions / cropped versions of an image so thats why i was going to use carrierwave. Currently its set up to store on file ...

MongoDB on EC2 server or AWS SimpleDB?

What scenario makes more sense - host several EC2 instances with MongoDB installed, or much rather use the Amazon SimpleDB webservice? When having several EC2 instances with MongoDB I have the problem of setting the instance up by myself. When using SimpleDB I have the problem of locking me into Amazons data structure right? What diff...

MongoMapper - manually setting an ObjectId failing with "illegal ObjectID format"

I've got a simple model object: class UserRating include MongoMapper::EmbeddedDocument key :idea_id, ObjectId key :rating, Integer end I'm trying to set an Idea_Id on this object with: user_rating.idea_id = ObjectId.new This throws: "illegal ObjectID format" This sure seems like simple code... The only oddity I am noticing ...

querying object in rails (no activeRecord, using mongo with mongomapper)

I've got a group of messages in mongo which I am retrieving in rails with @messages = current_user.user_messages(@user) I now want to select the number of messages which were created in the last week, so I thought I could take the @messages and query that directly with @countRecent = @messages.count(:conditions => {:created_at =>{'$...

What's a fast way to check if an item is the most recent version in mongodb?

I have a collection of items in mongodb that look like this (I'm using pymongo): {'type':'_sometype', 'name':'_somename', 'date':datetime, 'incoming':bool} type and name are not unique across items, so it is possible to have items with the same type and name but differing dates. The issue: sometimes I'll need to determine if an it...

Store dates in MongoDB as integer rather than MongoDate value

Are there any disadvantages to storing dates as integers (timestamps) in MongoDB rather than its MongoDate format? Because I'm having problems with Zend Framework and Doctrine ODM to read the data, since I get them returned as an array as DateTime object. Internally MongoDB seems to save them as Timestamps, but has its own object for it...

GridFS in Ruby: How to upsert?

Does GridFS have an upsert? For example, if i want to save an image with a specified _id, and one with that same _id already exists, i want it to overwrite (update) it. Otherwise, insert it. Thanks! Matt ...

How can I trace mongoDB queries

Hi guys, I'm running mongodb server as a windows service. How can i connect to it via console to trace executed queries? Best regards, Alexey Zakharov ...

Is GridFS fast and reliable enough for production?

I develop a new website and I want to use GridFS as storage for all user uploads, because it offers a lot of advantages compared to a normal filesystem storage. Benchmarks with GridFS served by nginx indicate, that it's not as fast as a normal filesystem served by nginx. Benchmark with nginx Is anyone out there, who uses GridFS alrea...

How to implement references in map-reduce databases?

I am starting to study map-reduce databases. How can one implement a reference in a map-reduce database, such as CouchDB or MongoDB? For example, suppose that I have drivers and cars, and I want to mark that some driver drives a car. In SQL it's something like: SELECT person_id, car_id FROM driver, car WHERE driver.car = car.car_id (T...

What's the best tutorial for learning Mongoid?

I'm new to Mongo DB and Mongoid (and still kinda new to Ruby on Rails). Since Ryan Bates dosen't happen to have a Mongoid Railscast, I need pointers to other good tutorials/screencasts. Thanks! ...

Any recommend pattern or strategies for data access from java to mongo db?

I'm just starting a project where I need to return POJOs from our mongo db. I did a quick search and found a few mappers in development but nothing extremely solid. What I'm looking for: 1) Ideally, as little additional code as possible to map POJO to mongodb (and vice versa) 2) Recommended strategy/pattern for access (regarding conne...

Searching within array within particular document in mongodb

I have a collection of the following sort of documents (taken from Mongo DB Docs: Schema Design for familiarity): db.students { name: 'Jane', scores: [ { course: 'math', grade: 'A'}, { course: 'biology', grade: 'B'}, { course: 'english', grade: 'C'} ] } If I already have the docume...

Executing MongoDB query in Node.js

I am trying to execute this MongoDB command in Node.js: db.events.group({ key : { 'timestamp.d' : true }, cond: { 'event_name': 'search' }, initial : { 'count' : 0, 'empty' : 0, 'redos' : 0 }, reduce : function(item, summaries){ summaries.count++; if (item.result_count == 0){ summaries.empty++; ...

An optional dict in the structure with MongoKit

I've got MongoKit structure like this: structure = { ... 'plugin': { 'id': unicode, 'title': unicode, 'description': unicode, ... } However, not all documents will have the plugin key. If they do, I'd like it to be validated against the structure. required_fields does not include plugin. (plugin isn't a required k...