mongodb

Using Sinatra and MongoDB - what's the recommended way to "keep alive" the mongodb connection between http requests?

I've used ASP.NET and now I'm working on a Sinatra/MongoDB app. With ASP.NET architecture, the connection to the database a given request uses comes from a pool of connections that the ADO.NET manages. The connections are kept alive in the pool between requests so that the cost of building and tearing down the connection isn't paid f...

Grouping by Nested Object Keys in MongoDB

with mongodb, is it possible to group results by a key found in an array of objects in a list? for example, lets say i have a table of survey responses (survey_responses), and each entry represents a single response. one or more of the questions in the survey is a multiple choice, so the answers stored could resemble: survey_responses....

Middleware for MongoDB or CouchDB with jQuery Ajax/JSON frontend

I've been using the following web development stack for a few years: java/spring/hibernate/mysql/jetty/wicket/jquery For certain requirements, I'm considering switching to a NoSQL datastore with an AJAX frontend. I would probably build the frontend with jQuery and communicate with the web application middleware using JSON. I'm leanin...

I need an advice about NoSQL/MongoDb and data/models structure

Hi everyone, Recently I'm exploring NoSQL Databases. I need an advice about how to store data in the most optimal and efficient way for a given problem. I'm targeting MongoDB, now. However it should be the same with CouchDB. Let's say we have these 3 Models: Story: id title User: id name Vote: id story_id user_id I want ...

MongoDB dbref in perl

Is there a way to do dbrefs using the Perl API? Its not here nor is it anywhere here. Here s a sample schema: book: name, publisher,isdn,{author} author : name,date of birth I could just add a field to serve as the reference but wanted to do it with dbref instead. Did I miss something? ...

MongoDB nested sets

What're the best practices to store nested sets (like trees of comments) in MongoDB? I mean, every comment can have a parent comment and children-comments (answers). Storing them like this: { title: "Hello", body: "Please comment me!", comments: [ { author: "Peter", text: "Hi there", ...

MongoDB: Is it possible to make a case-insensitive query?

Example: > db.stuff.save({"foo":"bar"}); > db.stuff.find({"foo":"bar"}).count(); 1 > db.stuff.find({"foo":"BAR"}).count(); 0 ...

Access DB Ref MongoDB

Whats the best way to access/query a DB Ref: UPDATE: users: name, groupref : {$ref:"groups",$id:"ObjectId ..." } } groups: name, topic, country,...,.. Assumption is that user belongs to only one group, how would I get all users for a group whose country starts with the letter 'A'? Country is a string. Also, how would it change if use...

Running MongoDB with Authentication

I am trying to figure out MongoDB in order to evaluate whether it is a route I would like to take for future applications or not. In order to deploy it sensibly on my server, I would have to run it with authentication enabled (i.e. with the --auth argument or with auth = true in the config file). Installation seems relatively straightfo...

is simpledb very much like mongodb? key/value type db?

is simpledb very much like mongodb? ...

NO-SQL reliable for small bussines app?

I'm deciding between go for a NON-SQL engine or a regular SQL one for a document managment system for small bussines. I have experience with firebird/sql server and found a good track of reliability (specially with firebird). This market is full of crappy "servers" (clon-made PC, the mayority), cheap harddisk, rarely use of RAID or any...

How do you do an AND query on an array in mongodb?

I have an array with tags which is part of a document, eg ["red", "green", "blue", "white", "black"] Now I want to find all documents, which have red AND blue. ...

Is MongoDB as efficient as a RDBMS with reporting style queries?

I know that MongoDB is a document style database so queries like select all employees with salary > 32000 aren't its speciality, but I noticed that you can indeed do things like this. My question is, are these queries comparable in performance to what you'd see in an RMDBS? Also, what about selecting the guts of an object? If you have a...

Logical OR for two different fields in $where queries in mongodb

How do you do a query like the one below, where I want hotels in London OR hotels which have hilton in their name? This query db.hotels.find({$where : "name = /hilton/i || city = /london/i"}) gives such an error error: { "$err" : "$where compile error" } Both queries separately work ok: db.hotels.find({$where : "city = /london/i"}) ...

Are there any tools for schema migration for NoSQL databases?

I'm looking a way to automate schema migration for such databases like MongoDB or CouchDB. Preferably, this instument should be written in python, but any other language is ok. ...

Has anybody actually used django-mongodb?

I can't find any documentation on this or any forum discussions. Has anybody at least gone through their testapp? I feel like there are errors in their code (deprecated from the most recent version of pymongo), but I've just started with pymongo and am not entirely sure. Are there any good resources on django-mongodb or is this project k...

Are MongoDB and CouchDB perfect substitutes?

I haven't got my hands dirty yet with neither CouchDB nor MongoDB but I would like to do so soon... I also have read a bit about both systems and it looks to me like they cover the same cases... Or am I missing a key distinguishing feature? I would like to use a document based storage instead of a traditional RDBMS in my next project. I...

Compressing a hex string in Ruby/Rails

I'm using MongoDB as a backend for a Rails app I'm building. Mongo, by default, generates 24-character hexadecimal ids for its records to make sharding easier, so my URLs wind up looking like: example.com/companies/4b3fc1400de0690bf2000001/employees/4b3ea6e30de0691552000001 Which is not very pretty. I'd like to stick to the Rails url ...

When to use Embedded Documents?

I am trying to figure out how to layout my database for a site I am working on. Here are my models: class User include MongoMapper::Document // keys here many :items many :likes end class Item include MongoMapper::Document key :name, String, :required => true many :likes end class Like include MongoMapper::Embedded...

MongoDB: What's a good way to get a list of all unique tags?

What's the best way to keep track of unique tags for a collection of documents millions of items large? The normal way of doing tagging seems to be indexing multikeys. I will frequently need to get all the unique keys, though. I don't have access to mongodb's new "distinct" command, either, since my driver, erlmongo, doesn't seem to impl...