MongoDB is a scalable, high-performance, open source, document-oriented database. This tag is used for questions related to the Java language bindings and drivers for MongoDB.
I came across an odd occurrence while using mongodb + their java driver.
When I do a grouping query the datatype for the key changes from an int to a double.
(ie. I am grouping on a key for 'hours', which is stored as an int within all the objects,…
I know that if I create a connection to MongoDB in Java to a replica set using a list of ServerAddresses (using this function) with ReadPreference.SECONDARY, the client will balance the reads across the replica set, preferring nodes with shorter…
I know that Java com.mongodb.Mongo objects are thread safe, but if I use the database returned from it to create a GridFS object, is that GridFS object also thread safe?
Thanks.
I am attempting to create a uberjar of my java project with a dependency for the mongodb-java-driver found here which includes the com.mongodb.* packages.
Currently I have tried using leiningen versions 2.0.0-preview4 and 1.7.1, and…
I am trying to gather all the hashtags i have in a collection of tweets in mongodb and i want to count how many times each hashtag appears in tweets. hcoll is the collection of hashtags that is created with this code.
BasicDBObject key = new…
I have
String toInsert = "somestring";
insert(toInsert);
and
insert(String toInsert) {
DBObject dbo = new BasicDBObject();
dbo.put("value" : toInsert);
}
In Mongo, this is saved as
{"value" : "somestring"}
But I would like it to be…
I am trying to run the following command via the mongo Java API - MapReduceCommand class. During debug time the MapReduceCommand mrc seems to hold the following.
{ "mapreduce" : "inColl" , "map" : "function mapf(){var vr = new…
In DAO class I use with Morphia I have replaced the String filed type to enums.Currency and I expect that everything will work fine, when the data is retrieved from the db:
was
public String currency;
now
public Currency currency;
where…
In sql the statement look like: UPDATE table SET table.password = pPassword WHERE (table._id = pid);
How does this work for Java and MongoDB?
function(){
BasicDBObject cBsonFilter = new BasicDBObject();
cBsonFilter.append(COL_id, new…
Been recently trying to compress within a single Map all the values that will go within my $set clause when performing an upsert to MongoDB.
However, this was previously done with a single typed Map[String, Long] which worked. However, since I know…
I am writing a parser for incoming JSON data with no definite structure for the values within the JSON. For example a given key within the parent JSON can have an integer or a string value. In some cases it can also be another JSON string. When…
Here is the problem,
I want to capitalise the first letter of a name in my existing
database, just wanted to know if there is any query so that i can make
it possbile.
what i want -- in my database so many names is in unformatted ways.. like…