mongodb

How to load initial data in MongoDB?

Does anyone know how to populate mongodb with initial data? For example, with a traditional SQL database, you can put all your SQL statements in a textfile, then load that using a SQL command. This is extremely useful for unit testing. Is it possible to do this with the mongo shell? For example, write down a list of shell statements int...

Mongo JSON document -> JSON -> BSON

I am working with Node.js to build a web socket server that uses mongodb. I am using node-mongodb-native as the library to access mongo db. When I call console.log(sys.inspect(item)) on an object from the db I get something that looks like this: { _id: { id: 'L?#&\u008e\u00ad\u000e\u008f\u0014\u0005\u0000\u0000' } , y: 3 , favorite_c...

mongodb union $or problems

I have a collection which is an action log between two users. It has a src_id and a dest_id. I'm a looking to fetch all the records that are actions between id1 and a list of ids - "ids = [id2, id3, id4]". The following two statements work properly: act_obs = self.db.action_log.find( {'src_id': id1, 'dest_id': {'$in': ids} } ...

Mongodb, sharding and multiple windows services

In order to get sharding to work I need to run two copies of mongod.exe. One as a shard and one as the config server. How can I install both mongod instances as windows services? ...

mongodb map function not called after upgrade to 1.6

I have an example to learn map-reduce in mongo, modified from: http://www.mongodb.org/display/DOCS/MapReduce#MapReduce-ShellExample2 // for timestamps function padZero(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } function printLog(l) { print(l.ts + '...

in mongodb, sharded collections do not accept scope in mapReduce?

I am experimenting with mongodb 1.6 and this thing is new to me. I notice that if I shard a collection, and then do a mapReduce, mapReduce doesn't accept the argument scope anymore: // some line in some example code... res = db.data.mapReduce(m,r,{scope: {log : log, padZero: padZero}}); And I got an error like this: Mon Aug 09 1...

Persisting with MySql and Replicating to Mong/Couch

Hi , I'm trying to move a reporting engine from a MySql DB (which is also the one used for batch jobs). while we stil need the benefits of an ACID DB for batch processes we have no need for them in reporting also map-reduce can benefit reporting much . do any of the two above have a way in which they can read the master logs (of mys...

How to catch an OperationFailure from MongoDB and PyMongo in Python.

I have been having a problem where after my mongodb connection to mongohq via pymongo goes idle for awhile (no queries), it will timeout. This is fine, but the connection the database is only created when the Django app is started up. It seems like it is reconnecting fine, but it needs to reauthenticate then. When the connection has died...

Norm.MongoException: Connection timeout trying to get connection from connection pool

Hi, I'm using Rob's mvc startesite http://mvcstarter.codeplex.com/ with ASP.Net MVC 2, Ninject2, NoRM (http://github.com/atheken/NoRM) and MongoDB. It works so fast and the developpement is even faster but I'm facing a big problem, I at some points, get connection timeout. I can't figure out what I'm doing wrong. I already asked a que...

How do I get mongoimport to work with complex json data?

Trying to use the built in mongoimport utility with mongo db... I might be blind but is there a way to import complex json data? For instance, say I need to import instances of the following object: { "bob": 1, "dog": [ 1, 2, 3 ], "beau": { "won": "ton", "lose": 3 } }. I'm trying the following and it looks like it loads everything into...

Why does my remote MongoDB connection require authentication on every query?

After fighting with different things here and there, I was finally able to get BottlePY running on Apache and run a MongoDB powered site. I am used to running Django apps, so I will be relating to that a bit in my question. The Problem Every time a page is loaded via BottlePY, the connection to the MongoDB database located on MongoHQ.c...

Best Practice Mongoid:NestedResources

Hello Mongo Friends, I'm starting off with a small Rails3:MongoDB:Mongoid project and came along some questions that's nature is more architectural. When to use nested resources, and how deep to nest? I'm not a friend of nested routes at all, but they become handy if not stacked deeper than 2 resources and document oriented database...

Is anyone storing raw SVG data inside mongodb?

I'm working on a project where I'm looking to store raw svg data inside my mongodb. Right now, it appears a bit goofy because I need to escape the svg string like so: { "_id" : ObjectId("4c61e60d4d02da615f175b6e"), "name" : "Triangle", "svg-data" : "<?xml version=\"1.0\" encoding=\"utf-8\"?> <!-- Generator: Adobe Illustrator 14.0.0, SV...

What's the way to translate model attributes in rails with mongoid?

I've problem with mongoid and model translations. When I'm trying use mongoDB on my model I haven't idea to translate attributes and model name. It's normally in *.yml files but in this time this doesn't work. Any ideas? ...

Ruby, Candy and SQL-like mongo stuff

So Candy is a really simple library for interacting with Mongo in Ruby. My poor SQL brain is having a tough time figuring out how I should map out this problem: There are users, there are things. Each thing was made by one user, but should be accessible to a subset of all users (specified within the thing). Leaving the specification of...

Is there a way to upsert a list with a single query?

Hi, I know this question has been asked before, but that's a different scenario. I'd like to have a collection like this: { "_id" : ObjectId("4c28f62cbf8544c60506f11d"), "pk": 1, "forums": [{ "pk": 1, "thread_count": 10, "post_count": 20, }, { "pk": 2, "thread_count": 5, ...

Data object storage - Can table JOIN's do what single table SELECT's cannot?

Now that "NOSQL" or "object only" storage systems like MongoDB or memcached are really picking up steam in the world. I was wondering if there are any requests that cannot be performed on them that can be performed using multiple object joins (in SQL that is JOIN "table"). In other words, are there any multi-table queries that cannot be ...

MongoDB geo distance/radius to useful units

I'm using MongoDB geospatial queries -- $near, geoNear, etc. -- and I'd like to know how to turn the 'dis' result of the 'geoNear' command as well as the 'radius' argument for $within queries to/from readable units like miles or kilometers. ...

How to $set sub-sub-array items in MongoDB

I'm developing a webapp which has a portal-ish component to it (think like multiple panels that can be drug around from column to column and added or removed). I'm using MongoDB to store this info with a format like so... { _id: ObjectId(...), title: 'My Layout', columns: [ { order: 1, width:...

How to set the hilo sequence starting value in MongoDB Norm?

Hi, i imported a lot of existing values into my mongodb via the norm driver (including the "old" id - integer value). Now i got duplicate key errors from time to time. To solve this, i have to set the starting value for the hilo sequence manually. How can this be done? Thanks in advance ...