mongodb

How to handle pagination queries properly with mongodb and php?

Am I doing this right? I went to look at some old PHP code w/ MySQL and I've managed to get it to work, however I'm wondering if there's a much "cleaner" and "faster" way of accomplishing this. First I would need to get the total number of "documents" $total_documents = $collection->find(array("tags" => $tag, "seeking" => $thi...

Which of CouchDB or MongoDB suits my needs?

Where I work, we use Ruby on Rails to create both backend and frontend applications. Usually, these applications interact with the same MySQL database. It works great for a majority of our data, but we have one situation which I would like to move to a NoSQL environment. We have clients, and our clients have what we call "inventories"--...

Simulating relations in MongoDB

Being one of the most popular NoSQL solutions MongoDB has most of the advantages of this approach. But one issue I'm still struggling with is how reflect object relations in NoSQL data store, specifically - MongoDB. For example, let's consider a simple data model: User, Post and Comment. It is clear to me that comments have no value on ...

when to index on multiple keys in mongodb

say I have an Item document with :price and :qty fields. I sometimes want to find all documents matching a given :price AND :qty, and at other times it will be either :price on its own or :qty on its own. I have already indexed the :price and :qty keys, but do I also need to create a compound index on both together or are the single key...

Update values in array in MongoDB

I'm trying to come up with a way to update the values in an array of objects in mongo. I have a collection which looks like [ { CourseName: '', Sessions: [ { _id: null, //oops I didn't set this in the import Name: 'blah', Location: 'moon' }] ...

Exception in morphia-0.93-SNAPSHOT.jar

Hi guys, I am trying to mapp pojo class to mongodb using morphia-0.93-SNAPSHOT.jar but it is throwing exception that "java.lang.NoClassDefFoundError: org/bson/types/CodeWScope" which is bson's exception.So I am not able to run those programs.So please can anybody help me to solved this problem ...

NoRM MongoConfiguration

Something is wrong with my MongoConfiguration I think, I read the following on NoRM's google group: On Mar 22, 3:14 am, Andrew Theken wrote: It can easily live in the object: public class POCO{ //implicitly runs one time. static POCO(){   MongoConfiguration.Initialize(cfg=> cfg.For<POCO>(f=>     {        f.ForProp...

MongoDB equivalent of SQL "OR"

So, MongoDB defaults to "AND" when finding records. For example: db.users.find({age: {'$gte': 30}, {'$lte': 40}}); The above query finds users >= 30 AND <= 40 years old. How would I find users <= 30 OR >= 40 years old? ...

MongoDB Schema Design - Many small documents or fewer large documents?

Background I'm prototyping a conversion from our RDBMS database to MongoDB. While denormalizing, it seems as if I have two choices, one which leads to many (millions) of smaller documents or one which leads to fewer (hundreds of thousands) large documents. If I could distill it down to a simple analog, it would be the difference between...

Storing one column in a NoSQL DB?

In an app I am working on, we use a MySQL database and want to store articles in a table. Rather than store them in a SQL DB, we were looking at just storing the key to the article in a NoSQL db. Is this a good problem to solve using NoSQL, or should we just create another table in MySQL and store the large amounts of text there? We a...

inheritance in document database?

i am wondering because i searched the pdf "xxx the definitive guide" and "beginning xxx" for the word "inheritance" but i didn't find anything? am i missing something? because i am doing a tablePerHierarchy inheritance with hibernate and mysql, does that become deprecated for some reason in xxx? (replace xxx with the "not only sql" data...

MongoMapper, Rails, Increment Works in Console but not Controller

I'm using mongo_mapper 0.7.5 and rails 2.3.8, and I have an instance method that works in my console, but not in the controller of my actual app. I have no idea why this is. #controller if @friendship.save user1.add_friend(user2) ... #model ... key :friends_count, Integer, :default => 0 key :followers_count, Integer, :default => 0 ...

What does "Document-oriented" vs. Key-Value mean when talking about MongoDB vs Cassandra?

What does going with a document based NoSQL option buy you over a KV store, and vice-versa? ...

What does "Document-oriented" vs. Key-Value mean when talking about MongoDB vs Cassandra?

What does going with a document based NoSQL option buy you over a KV store, and vice-versa? ...

can I use MongoDb in server-less mode?

I'm considering using MongoDb for a backing store for a WPF app that I'm building. Mostly just to get some exposure to NoSQL. Ideally I'd like to make a mongodb database, put it in my application's root folder (or ./data) and connect to it with LINQ -- without having mongo.exe running. I did something similar recently with SQLite and fou...

has_one vs. defining as a Key for Embedded documents for MongoMapper and MongoDB

The Source code is class RealTimeDetail include MongoMapper::EmbeddedDocument key :url, String key :method, String end class TargetFeed include MongoMapper::Document key :name, String, :null => false key :feed_type, String, :null => false has_one :real_time_detail end When I do target_feed.real_time_detail = RealTi...

PHP + MongoHQ : MongoCursorException

Hi, I'm trying to use mongodb with PHP. For that, I have created a MongoHQ instance, but for some reasons when I try to insert something or any other operation from my php server I get the following error: Fatal error: Uncaught exception 'MongoCursorException' with message 'unauthorized for db [datab] lock type: -1 ' in C:\Program File...

Can we use MongoDB with ORMs we used to use with relational databases, such as linq2sql, entity framework, subsonic,...?

I want to know if its possible based on your experience to use our previous experiences using .net ORMs with nosql db such as MongoDB. And also if you know samples doing this please refer in your answer. ...

How to manually create a DBRef using pymongo?

I want to create a DBRef manually so that I can add an additional field to it. However, when I try to pass the following: {'$ref': 'projects', '$id': '1029412409721', 'project_name': 'My Project'} Pymongo raises an error: pymongo.errors.InvalidName: key '$id' must not start with '$' It would seem that pymongo reserve the $ for the...

In MongoDB, how can I replicate this simple query using map/reduce in ruby?

Hi, So using the regular MongoDB library in Ruby I have the following query to find average filesize across a set of 5001 documents: avg = 0 total = collection.count() Rails.logger.info "#{total} asset creation stats in the system" collection.find().each {|row| avg += (row["filesize"] * (1/total.to_f)) if row["filesize"]} ...