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.
Given this document saved in MongoDB
{
_id : ...,
some_key: {
param1 : "val1",
param2 : "val2",
param3 : "val3"
}
}
An object with new information on param2 and param3 from the outside world needs to be saved
var…
I use spring data mongodb.
I want the records between two dates. The following MongoDB Query works:
db.posts.find({startDate: {$gte: start, $lt: end}});
My attempted Spring data query object code translation does not work:
Query query = new…
How do I export the results of a MongoDB command to a flat file
For example, If I am to get db.collectionname.find() into a flat file.
I tried db.collectionname.find() >> "test.txt" doesnt seem to work.
I am trying to find documents in MongoDB by searching on "_id" key. My document looks like this-
{
"_id" : ObjectId("4f693d40e4b04cde19f17205"),
"hostname" : "hostnameGoesHere",
"OSType" : "OSTypeGoesHere"
}
I am trying to search this…
I'm seeing a strange issue using the casbah / java driver.
I keep running into the following exception when the driver tries to create a response from mongo:
Oct 16, 2012 10:45:07 AM com.mongodb.DBTCPConnector$MyPort error
SEVERE: MyPort.error…
I want to mock a method with signature as:
public T documentToPojo(Document mongoDoc, Class clazz)
I mock it as below:
Mockito.when(mongoUtil.documentToPojo(Mockito.any(Document.class), Mockito.any(WorkItemDTO.class)))
But I get error…
I am using MongoDB in my application and was needed to insert multiple documents inside a MongoDB collection .
The version I am using is of 1.6
I saw an example here
http://docs.mongodb.org/manual/core/create/
in the
Bulk Insert Multiple…
I get this error on a find call (default Java Driver) after a period of inactivity. I tried to add a manual heartbeat (writing to a capped collection), but it didn't help. I only get the issue while being connected to an instance on compose (i.e.…
I am newbie to mongodb. May I know how to avoid duplicate entries. In relational tables, we use primary key to avoid it. May I know how to specify it in Mongodb using java?
I asked this same question on the mongodb-user list: http://groups.google.com/group/mongodb-user/browse_thread/thread/b3470d6a867cd24
I was hoping someone on this forum might have some insight...
I've run a simple experiment comparing the…
I want to delete all documents in a collection in java. Here is my code:
MongoClient client = new MongoClient("10.0.2.113" , 27017);
MongoDatabase db = client.getDatabase("maindb");
db.getCollection("mainCollection").deleteMany(new…
I have a mongodb collection term with following structure
{
"_id" : "00002c34-a4ca-42ee-b242-e9bab8e3a01f",
"terminologyClass" : "USER",
"code" : "X67",
"terminology" : "some term related notes",
"notes" : "some notes"
}
and a…
I'm new to Spring Data with MongoDB and would like to have an automagically generated query method inside my MongoRepository extension interface which requires filtering, sorting and limiting.
The query looks like this:
// 'created' is the field I…