mongodb

MongoDB Performance Based on Document Size

I've been playing around with the samus mongodb driver, particularly the benchmark tests. From the output, it appears the size of the documents can have a drastic effect upon how long operations on those collections take. Is there some documentation available that recommends what balance to strive for or some more "real" numbers aroun...

Defining models with Mongoid for this database structure

Hey I'm trying to build a rails 3 app with Mongoid (for MongoDB). What I'm now trying to do: Languages: id (automatically created, right?) name (e.g. English) code (e.g. en_US) Languages_Texts: id (see above...) name (e.g. hello_world) Translations: id (see above...) translation (e.g. Hello, world!) I hope this database sc...

Undo convertToCapped to a collection

In MongoDB you can convert a collection into a capped collection with the command convertToCapped, but is there a way to revert this change so a capped collection goes back to normal? ...

Update MongoDB field using value of another field

In MongoDB, is it possible to update the value of a field using the value from another field? The equivalent SQL would be something like: UPDATE Person SET Name = FirstName + ' ' + LastName And the MongoDB pseudo-code would be: db.person.update( {}, { $set : { name : firstName + ' ' + lastName } ); ...

Polishing a mongodb query

Hello, This is my current query: Using Java+mongoDB { BasicDBObject select = new BasicDBObject(); select.put("info.name.fn", 1); DBCursor cursor = collection.find(new BasicDBObject(), select); while (cursor.hasNext()) { System.out.println(cursor.next()); } It gives an output as: { "_id" : { "$oid" : "...

MongoDB PHP: How do I get ObjectId with a JSON feed? (it's blank)

I'm storing a file through GridFS and saving the id like so: $file_id = $gridfs->storeUpload('texture'); $item = array( 'name'=>$_POST['name'], 'description'=>$_POST['description'], 'price'=>$_POST['price'], 'categories'=>$category_array, 'tags'=>$tag_array, 'file'=>$file_id ); $collection->insert($item); and...

How to update mongodb collections.

My collection structure is: col1 = {'class':'12', 'roll':[1, 2, 3, 4]} Now I want to update the collection col1 to col1 = {'class':'12', 'roll':[1, 2, 3, 4, 5]} I added another roll number here. How to update this in pymongo. ...

Ruby Mongo or Mongoid concurrency problem

I am having what I think must be a concurrency problem. I am using passenger, rails 2.3.5, mongoid 1.9.2, and mongo ruby driver 1.0.9. I am using jQuery to request data that is pulled from MongoDB and then rendered in the browser. Everything is working great until I started to make two such requests at the same time. In the model the...

How to precisely control your queries with MongoMapper

I have an index like this in my database (for my table entries): {"created_at": -1, "search_id": 1, "services":1} I can make use of that index if I perform a search in the Mongo console like this: db.entries.find({'search_id':1, 'services':2}).sort({'created_at': -1}) (if I perform an explain() on that query I can see that it's usi...

CouchDB and MongoDB really search over each document with JavaScript?

From what I understand about these two "Not only SQL" databases. They search over each record and pass it to a JavaScript function you write which calculates which results are to be returned by looking at each one. Is that actually how it works? Sounds worse than using a plain RBMS without any indexed keys. I built my schemas so they d...

MongoDB extract only the selected item in array

Suppose you have the following: // Document 1 { "shapes" : [ {"shape" : "square", "color" : "blue"}, {"shape" : "circle","color" : "red"} ] } // Document 2 { "shapes" : [ {"shape" : "square", "color" : "black"}, {"shape" : "circle", "color" : "green"} ] } do query: db.test.find({"shapes.color":"red"}, {"shapes.colo...

I need to store & query "relational, hierarchical, graph, document" hybrid data. I'm looking for the best DB solution.

I am working on what is currently a pet project. Soon it will be going into mainstream production. My biggest barrier is the data storage. The bulk of the data is "document" with specific indexes that would span across several types of data. So a single collection with indexing would work just fine. I know MongoDB, Caché, and M will ha...

MongoDB Stored Procedure (javascript function) that updates documents before it returns them as results?

I'm in the process of converting a system from sql server to mongodb. I believe the project is a good candidate for mongodb, but that's not my question. In the sql database, i have a stored procedure that I use to return a set of records that need processing. So, I have Processed BIT and LastProcessingRequestDate DATETIME fields in th...

How to test/spec Sinatra & MongoDB API with Cucumber?

I want to spec a Sinatra server that receives HTTP requests, stores things in MongoDB, and responds with JSON. How would I spec both the MongoDB entries and the responses? I'd like to use Cucmber and RSpec to do this cause I hear they're hot, but I'm not really good with them yet. Thanks! Matt ...

Lazy loading in MongoDB with NoRM

I have a model similar to this: (simplified) Question: public class Question { public string QuestionID { get; set; } public string Title { get; set; } public string Body { get; set; } public List<Answer> Answers { get; set; } } Answer: public class Answer { public string QuestionID { get; set; } public str...

Berkeley DB: how does it compare to MongoDB?

Recently, I've been digging into various types of DBs. I need to store & query “relational, hierarchical, graph, document” hybrid data. I'm looking for the best DB solution. I can't find much data about Berkeley DB. Most of the stuff on their website is written by the marketing dept. One of the PDFs makes it sound like it handles relati...

How is "foo" different from foo, in a mongodb key:value pair?

When I see a field:value pair as "name":"foo" and "name":foo what is the difference between the two? Are both the values supposed to be strings? And what about "age":3 and "age":"3" Is the first one an integer? I am confused. Thanks. ...

Implementing a blog with MongoDB and NoRM: Relationships?

Hi, I'm starting to learn MongoDB, using the NoRM C# driver in an ASP.NET MVC project. I'm just writing POCO classes right now, and have question on how to implement relationships between Blog Posts, Comments, and Tags. I think I have the Post & Comment, but not sure what to do on the Tags. In SQL, they are many-to-many relationship, how...

MongoDB - ASp.net - Questions

Hi, I’am starting a personal web project. Which I hope it grows fast. It will do a lot of text inserts and searches in this project. So it seems MongoDB a good option. But of course there is not a hosting of asp.net and mongoDB. Also I do not want to expend a lot of money, at the beginning. So I have the idea of contract https://mo...

How to pull out Object ID in mongodb and search against it?

Please note, "user_id" in my plans collection is NOT an object_id. I have it stored in the plans collection to reference the user's _id in the user_accounts collection. I thought about storing usernames across all collections in order to reference the user, but that wouldn't be idea should the user wishes to change his/her username. // ...