mongodb

MongoDB/py-mongo for queries with date functions

Im looking to use a document database such as MongoDB but looking through the documents I cant find much on queries that involve date functions. For example lets say that I'm asking one of the following questions of the DB: "Tell me all the people who bought a product on tuesday" "Get me all sales and group by month" They are random ...

Are Python global variables thread-safe?

edit: im asking if global variables are safe in a single-threaded web framework like tornado im using the mongoengine orm, which gets a database connection from a global variable: _get_db() # gets the db connection im also using tornado, a single-threaded python web framework. in one particular view, i need to grab a database conne...

MongoDB and CodeIgniter

Can anyone assist in pointing me to a tutorial, library, etc. that will allow me to work with MongoDB from CodeIgniter? Any help is really appreciated. ...

Storing addtional info about a document in Mongo Mapper through a many :in => Array

I have a many to many relationship between Pumps and Parts. I am storing the Part ids in the Pump document. I would also like to store how many Parts are used in a particular Pump. Here's what I have, in short class Pump include MongoMapper::Document key :number, String key :desc, String key :part_ids, Array many :parts, :i...

activerecord and mongo / mongo-mapper bridge

I have a project which I have used Active Record and which I'd like to add some new features using MongoDB. Rather than re-invent the wheel and re-write my entire site, how can I integrate 2 models together, one which use MongoMapper and the other ActiveRecord (postgres). I've found that others have done it successfully, but no example...

Mongodb - what's the best way to do validation of data?

What's the best way to validate data being inserted or updated into Mongo? Is it to wrote some sort of server executed Javascript code that does the validation? Thanks d ...

mongodb data design question

I'm trying my first application with mongodb on Rails using mongo_mapper and I'm weighing my options on an STI model like below. It works fine, and I will of course add to this in more ways than I can currently count, I just curious if I wouldn't be better off with Embedded Documents or some such. I'd like my models to share as much as...

MongoDB query to return only embedded document

assume that i have a BlogPost model with zero-to-many embedded Comment documents. can i query for and have MongoDB return only Comment objects matching my query spec? eg, db.blog_posts.find({"comment.submitter": "some_name"}) returns only a list of comments. edit: an example: import pymongo connection = pymongo.Connection() db = conn...

Describing Child objects with Cucumber/MongoDB

Ok, total Cucumber newbie here so please be gentle. As a learning Ruby/Cucumber/MongoDB endeavor I'm building a simple contact manager. I have a Person (parent) model and an have been able to write a simple test as follows: Scenario: Show people Given the following person exists | firstname | lastname | | Bob | Jones | W...

MongoDB : '$err: name has to be a string' with $where

I've been trying to use the $where functionality with a Mongo database but I always get the same error message each time... $err: name has to be a string It doesn't matter what type I actually use (string eval, function, etc) - I get the same message each time. I've even gone as far as to try the examples listed on their website and st...

Python, mongo + spider monkey

Ok, so this isn't exactly a question that I expect a full answer for but here goes... I am currently using a python driver to fire data at a mongo instance and all it well in the world. Now I want to be able to pull data from mongo and evaluate each record in the collection. Now I need to pass in to this evaluation a script that will lo...

Pros and cons of ways of storing an unsigned int without an unsigned int data type

I have values that are 64-bit unsigned ints, and I need to store them in mongodb, which has no unsigned int type. I see three main possibilities for storing them in other field types, and converting on going in and out: Using a signed int is probably easiest and most space efficient, but has the disadvantage that they're not human reada...

MongoDB: Limiting results from a $gt query (from pymongo)

Hi there, I'm gathering some statistics from a web service, and storing it in a collection. The data looks similar to this (but with more fields): {"downloads": 30, "dt": "2010-02-17T16:56:34.163000"} {"downloads": 30, "dt": "2010-02-17T17:56:34.163000"} {"downloads": 30, "dt": "2010-02-17T18:56:34.163000"} {"downloads": 30, "dt": "201...

What are some "mental steps" a developer must take to begin moving from SQL to NO-SQL (CouchDB, FathomDB, MongoDB, etc)?

I have my mind firmly wrapped around relational databases and how to code efficiently against them. Most of my experience is with MySQL and SQL. I like many of the things I'm hearing about document-based databases, especially when someone in a recent podcast mentioned huge performance benefits. So, if I'm going to go down that road, what...

MongoDB Get names of all keys in collection

Hi, I'd like to get the names of all the keys in a MongoDB collection. For example, from this: db.things.insert( { type : ['dog', 'cat'] } ); db.things.insert( { egg : ['cat'] } ); db.things.insert( { type : [] } ); db.things.insert( { hello : [] } ); I'd like to get the unique keys: type, egg, hello Cheers ...

TG2.1: Proper location to store a database session instance?

I am using a custom database (MongoDB) with TG 2.1 and i am wondering where the proper place to store the PyMongo connection/database instances would be? Eg, at the moment they are getting created inside of my inherited instance of AppConfig. Is there a standard location to store this? Would shoving the variables into the project.model....

SQLite-like alternative for MongoDB?

I'm looking for a document-oriented db with a Ruby API that has SQLite-like properties: self-contained, serverless, zero-configuration. Are there light alternatives to MongoDB or CouchDB? Is RDDB a possibility? If not, what are the best paths to walk then? ...

Ruby, MongoDB: How to share a Cursor between threads?

The following does not work. The call to resources.next_document within the thread returns nil. The same call without threading works as expected. Any MongoDB experts out there? :P resources = db[Resource::COLLECTION].find number_of_threads.times do threads << Thread.new do while resource = resources.next_document ...

Problem using easy_install on Windows 7, 64 bit. (cannot find python.exe)

Hi, I have just now installed Python 2.6 on my Windows 7 (64 bit) Lenovo t61p laptop. I have downloaded Sphinx and nose and apparently installed them correctly using python setup.py install (at least no errors were reported during the installation). Now I am trying to install pymongo using easy_install but I am not having much su...

MongoDB: What is connection pooling and timeout?

So my Passenger spins up 5 instances of my Rails app I connect to MongoDB using Connection.new("localhost", 3000, :pool_size => 1, :timeout => 5) Why would I need a "pool of connections" if I only incur overhead when starting up my Rails app, not per request? Why would a single process need more than 1 connection? And what is the ...