mongodb

MongoDB + PHP Item wont remove()?

I'm not sure what I'm doing wrong, but with MongoDB and PHP i'm trying to do this: $db->textures->remove(array("_id"=>$_GET['texture_id']),array("safe" => true)) But nothing happens. I did a print_r and it says: Array ( [err] => [n] => 0 [ok] => 1 ) ...

Secondary-only nodes in mongodb Replica set

I am working on a project where I want to have the ability to specify that certain nodes of the replica set can never be primary nodes ie in case of a failure where all primary capable nodes die the system should be reduced to a read-only state till some primary capable node comes up. Is this possible? If yes how? If not what is the best...

How come when I push "up" on MongoDB's console, it doesn't cycle through my previous command?

Instead, it displays this: ^[[A^[[A ...

How come a document in MongoDB sometimes gets inserted , but most often don't?

con = pymongo.Connection('localhost',27017) db = con.MouseDB post = { ...some stuff } datasets = db.datasets datasets.insert(post) So far, there are only 3 records, and it's supposed to have about 100... ...

MongoDB: Specifying which fields to return in group() query

How can I specify which fields to return in a group() query? find() has fields parameter; group() doesn't. ...

What is the better way to store an arbitrary key:value array in mongodb

I have an array of key values {val1: [{gender:male}, {age:23}, {favorite-color:red}] } The thing about this array is that in no way is it structured and in no way am I ever guaranteed to see the same key value again. For example I could see the following for val2 {val2: [{sex:male}, {hair-color:red}, {height:6'1"}] } My quest...

When I do Geospatial querying in MongoDB, how do I also return the distance from my desired point?

for post in db.datasets.find({"loc":{"$near":[50,50]}}).limit(10): How do I get the distance between the document and "50,50"? ...

Node.js framework with sessions support in MongoDB

I am looking for a node.js framework which is capable of tracing user sessions via cookies/storage on the server side. Storage has to be in MongoDB ...

How do you query this in Mongo? (is not null)

db.mycollection.find(HAS IMAGE URL) ...

Java MongoDB Driver Connection Question

Im using the MongoDB Java driver in a java web app. One question I want to ask is do i run Mongo.close() whenever Im doing doing a query , or can I keep it open and run other queries on it and close it when my application ends. ...

Rails: Store JSON in MongoDB

Hello, I am getting multiple similar JSON object from a remote site and looking to store them in a local MongoDB. What would be the best way to do this ? (Preferably via Mongoid or Mongo-mapper gems) Thanks ...

MongoDB pull array element from a collection

Hi, I have a mongodb object as follows: array ( '_id' => new MongoId("4cc97fb0247ae8747ec5fefb"), 'posts' => array ( 0 => array ( 'comment' => 'Eamorr', 'fromUname' => 'Eamorr', 'time' => 1288273840, 'UTC' => '2010-10-28T14:50:40+01:00', 'ip' => '127.0.0.1', 'id' => '123lasdfiqwoei28a...

How does MongoDB index arrays?

In MongoDB, if I were to store an array (say "red", "blue") in a field "color", does it index "red" and "blue" so I could query for "red", for example, or does in make {"red", "blue"} a composite index? ...

Problem converting mongodb id (_id) to string

Im having serious issues converting mongo id from object to string. The following code $cursor = $connection->mydb->collectn->findOne(); var_dump($cursor['_id'].''); var_dump((string) $cursor['_id']); returns string(12) "Object id #6" while what I was expecting is a textual representation of the hex digits of the id. It however wo...

How connect to db depending on @request.host value?

How connect to different db depending on @request.host value? Using Sinatra and MongoDB with Mongoid. I need to read a Sintra application's menu, data ... from different databases. I wish to deploy it only in one place and depending on request.host(subdomain) value to serve the specific pages. ...

MongoDB: Query by date

In a MongoDB database, I have a collection of items, and each item stores its creation date. I need to query this collection by date. I tried: db.items.findOne({date:{new Date(1285947037*1000)}}) but it isn't returning anything. I got that timestamp using PHP ($date->sec, where $date is a MongoDate object from the database). So wha...