mongodb

Is it possible to execute a function in Mongo that accepts any parameters?

I'm looking to write a function to do a custom query on a collection in Mongo. Problem is, I want to reuse that function. My thought was this (obviously contrived): var awesome = function(count) { return function() { return this.size == parseInt(count); }; } Executed that function in the Mongo console, and then proceeded to ...

Traditional SQL vs MongoDB/CouchDB for simple python app

Say I got an traditional SQL structure like so: create table tags (id PRIMARY KEY int, tag varchar(100)); create table files (id PRIMARY KEY int, filename varchar(500)); create table tagged_files (tag_id int, file_id int); I add some tags: insert into table tags (tag) values ('places'); insert into table tags (tag) values ('locations...

MongoDb ObjectId on Apache Thrift.

How can I send MongoDb ObjectId using Apache Thrift without decoding/encoding to string? ...

Multiple inequality conditions (range queries) in NoSQL

Hi, I have an application where I'd like to use a NoSQL database, but I still want to do range queries over two different properties, for example select all entries between times T1 and T2 where the noiselevel is smaller than X. On the other hand, I would like to use a NoSQL/Key-Value store because my data is very sparse and diverse, a...

Updating a specific key/value inside of an array field with MongoDB

As a preface, I've been working with MongoDB for about a week now, so this may turn out to be a pretty simple answer. I have data already stored in my collection, we will call this collection content, as it contains articles, news, etc. Each of these articles contains another array called author which has all of the author's information...

Getting geospatial indexes to work in MongoDB 1.4.3

I wanted to try geospatial indexes with MongoDB, but all I get is > db.map_nodes.find( { coodinate: { $near: [54, 10] } } ) error: { "$err" : "invalid operator: $near" } and > db.map_nodes.runCommand({geoNear:"coordinates", near:[50,50]}) { "errmsg" : "no such cmd", "bad cmd" : { "geoNear" : "coordinates", "n...

MongoMapper can't save a document with simple example

Hi all, I'll admit I'm still new to Ruby and now mongoDB so i'm guessing i'm doing something dumb. For a test I have this code called tester.rb: require 'Mongo_Mapper' MongoMapper.database = "myTestDB" class Person include MongoMapper::Document key :first_name, String key :last_name, String end person = Person.new(:first_name =...

All object properties are being saved, is it possible to only persist the fields that I've mapped?

I'm using Doctrine 2 ODM (with MongoDB). My Document model: class Users_Model_User { public $id; public $username; public $password; public $myRuntimeProperty = 'some value'; } My Document mapping in YAML: Users_Model_User: db: my_db collection: users fields: id: fieldName: id id: true usernam...

Ruby and MongoDB: Traversing arbitrary BSON document retrieved from mongomapper

In Ruby, how can I traverse an arbitrary document retrieved from a collection using something like mongomapper? Let's say the document looks something like this: mydocs = [{"title":"my title", "description":"hello world", "comments":[{"user":"me","text":"this"},{"user":"him","text":"that"}] }, {.....} ] ...

How to specify to NOT map an object Property in MongoDB with NORM

Hi, I have a calculated property in my object that I don't want to save to the DB, is there a way I can specify that? Like this one as an exemple : public virtual string FullInfos { get { var html = Contact1Info; html += Contact2Info; return html; } } Where Contact1...

Monitoring Mongo for changes with Node.js

I'm using Node.js for some project work and I would like to monitor my Mongo database (collection) for changes, basically fire an event if something gets added. Anyone know if this is possible? I'm using the node-mongodb-native drivers. If it's not I'd also like any available pointers on pushing data from the server (run with node) to ...

How do I get the ID of an object after persisting it in PyMongo?

I have a PyMongo newbie question: If collection is a PyMongo Collection and I use it to save an object with obj = {'foo': 'bar'} collection.insert(obj) then MongoDB automatically generates an _id field for obj; once can confirm this with print obj which yields something like {'foo': 'bar', '_id': ObjectId('4c2fea1d289c7d837e000000...

Connect to remote MongoDB instance from ASP.NET

I'm having some trouble nutting out why I'm unable to connect to a new database I've created at MongoHQ. I want to include the correct connection string in my Web.config file and have my Mongo object refer to that for the database connection. The connection strings (edited, obviously) are: Public Access mongo flame.mongohq.com...

Securing document-style databases (MongoDb, CouchDb, RavenDb) for client (browser) access

Document databases that support REST-style JSON over HTTP access seem ideal for supporting AJAX-rich applications where the browser is making direct calls to the database, bypassing the traditional web server / application logic components. An example of this might be retrieving user preferences once a user has been authenticated. (BBC H...

Select distinct rows from MongoDB

How do you select distinct records in MongoDB? This is a pretty basic db functionality I believe but I can't seem to find this anywhere else. Suppose I have a table as follows -------------------------- | Name | Age | -------------------------- |John | 12 | |Ben | 14 | |Robert | 14 |...

mongodb and mongomapper

hi i have a rails app that currently uses activerecord to store and query products. Each product has a category and sub category and each sub category is defined by multiple field that i can create within the application. From this when a user wants to input a specific product, they are pressented with the relevent form fields. This ...

How to do an order by not case sensitive

I'm starting to work with MongoDB and NoRM and I would like to do an orderBy that is not Ccase sensitive, is it possible? Thanks for the help! ...

MongoDB, .NET MVC

I am building a library using mvc, mongodb and asp.net membership. When a user browses the site logged in (logged out is auto set to preview) I need to check if they have purchased the current movie and if they have they can see the full set of features otherwise they have to purchase the video or watch the preview. I have a Movie mode...

mongodb is not inserting big integer correctly (tweet id)

EDIT: it turns out it's NOT a problem.. pfew! phpMOadmin is not able to display the bigint (probably server apache settings i didn't care).. not mongoDB is unable to save... u.kodingen.com/1fMs5Z i requested from CLI, and it comes back just fine! sorry mongodb. when i insert tweet to mongodb, it's id e.g. 16906830606 becomes -2745497...

Complex hash editing with MVC/Padrino ruby 1.8.x

I'm new to MVC. I'm using Padrino with MongoMapper and Haml to try to create this application. I have a database of items, each of which has a hash associated with it called 'params'. This hash has some required keys, but mostly arbitrary/random keys. Some of the keys have a finite set of allowable values. For example: item.params["pa...