mongodb-java Questions
4
Solved
I have the following structure in my document:
{
_id : ObjectId("43jh4j343j4j"),
array : [
{
_arrayId : ObjectId("dsd87dsa9d87s9d7"),
someField : "something",
someField2 : "something2"
}...
Ballocks asked 15/9, 2011 at 4:49
8
Solved
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 ...
Pallaton asked 10/10, 2012 at 16:20
4
Solved
We are trying to setup our own Converters for Spring Data Mongo and having problems with it.
Seems like Spring never calls for registerConvertersIn on CustomConversions and thus our custom conver...
Ation asked 10/12, 2015 at 22:0
1
Hello I have this document
{
email: "[email protected]",
list: [
{
"product": "Car",
"price": 18
},
{
"product": "Boat",
"price": 20
}
]
}
I am wondering how to identify the doc...
Varico asked 15/5, 2020 at 22:33
2
I want to store different data to one collection in MongoDb and have Spring data beans with appropriate field..
Sorry, I've skipped details.
Parent bean:
class A
int a
Childs:
class B extend...
Gummous asked 9/1, 2012 at 19:28
2
Solved
We have a Scala server which uses the Java MongoDB driver as wrapped by Casbah. Recently, we switched its database over from an actual MongoDB to Azure CosmosDB, using the Mongo API. This is genera...
Nevillenevin asked 26/1, 2018 at 15:30
3
I want to create compound index on Age and Name in MongoDB through Java driver and here is my syntax:
coll.ensureIndex(new BasicDBObject("Age", 1),new BasicDBObject("Name", -1));
List <DBObje...
Peephole asked 15/7, 2012 at 1:22
3
Solved
I want to mock a method with signature as:
public <T> T documentToPojo(Document mongoDoc, Class<T> clazz)
I mock it as below:
Mockito.when(mongoUtil.documentToPojo(Mockito.any(Docum...
Guthrie asked 27/5, 2015 at 10:20
4
Imagine theres a document containing a single field: {availableSpots: 100}
and there are millions of users, racing to get a spot by sending a request to an API server.
each time a request comes, ...
Stet asked 22/6, 2019 at 6:34
2
I want to know if it's possible to insert blob data in mongodb. What is the procedure and is any other softwares required for this?
Devout asked 12/2, 2014 at 11:35
1
Solved
I want to execute non-blocking database queries through Spring Data accessing a MongoDB using MongoDB's Async Client API.
So far I've only seen the possibility to return a
java.util.concurrent....
Lamphere asked 25/1, 2016 at 23:8
4
Solved
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.getColle...
Clarkson asked 25/6, 2015 at 18:49
4
Solved
I am using a MongoDB in Version 3 and I created a database named 'logMonitor' and created a user like:
{
"_id" : "logMonitor.log",
"user" : "log",
"d...
Stoneblind asked 22/12, 2015 at 11:4
2
Solved
I want to create a capped collection from Java code. I found the syntax for creating it through JavaScript, but could not find an example for Java.
Mongo mongo = new Mongo("127.0.0.1");
DB db = mo...
Benoni asked 27/6, 2012 at 15:1
5
Solved
I'm trying to connect to a remote mongodb instance, but it keeps throwing an error.
Java code:
Mongo mongo = new Mongo("172.234.52.24");
DB db = mongo.getDB("myDB");
collection = db.getCollection...
Morula asked 30/5, 2013 at 17:21
4
Solved
I am using Mongo DB java driver to connect to mongo instance. Below is the code I am using to create the MongoClient instance.
try {
new MongoClient("localhost", 1111);
} catch (Exception e) {...
Pickaback asked 25/11, 2016 at 22:41
2
Just a quick question about something I've just experienced and I'm still thinking about why:
mongos> db.tickets.count({ "idReferenceList" : { "$in" : [ { "$oid" : "53f1f09f2cdcc8f339e5efa2"} ,...
Uralic asked 10/9, 2014 at 14:35
6
JSON.parse() from mongo (Java driver) returns either a BasicDBList or a BasicDBObject.
However, when migrating to mongo driver 3.x, what's the new parse method that returns either Document or Lis...
Broussard asked 23/12, 2015 at 13:38
3
Solved
I have a doc
{_id:NumberLong(1),gender:"M",vip:false}.
How to extract the type of individual field in Mongo with a query..
How to use typeof operator:
https://docs.mongodb.org/manual/core/shel...
Asphyxiate asked 19/2, 2016 at 11:8
4
I want to create the following document schema in mongoDB using the java driver
{
"_id": {
"$oid": "513e9820c5d0d8b93228d7e8"
},
"suitename": "testsuite_name",
"testname": "testcase_name",
"...
Sulphur asked 12/3, 2013 at 20:48
1
I'm using the Java mongodb driver version 3.8.0 and mongodb 3.6.3.
I created a watch on a collection with this:
MongoCursor<ChangeStreamDocument<Document>> cursor = collection.watch()...
Sorcim asked 8/9, 2018 at 22:48
5
We are reading from a local MongoDB all documents from a collections and performance is not very brillant.
We need to dump all the data, don't be concerned why, just trust it's really needed and t...
Philip asked 30/8, 2018 at 16:9
3
Solved
In the below query
{ $group : {
_id : { success:'$success', responseCode:'$responseCode', label:'$label'},
max_timeStamp : { $timeStamp : 1 },
count_responseCode : { $sum : 1 },
avg_value : {...
Readjust asked 22/3, 2013 at 6:59
5
Solved
I tried converting my String ID to MongoDB ObjectID
public class relevancy_test extends Object implements Comparable<ObjectId> {
public static void main(String[] args) throws UnknownHostExc...
Chellean asked 10/4, 2015 at 5:9
3
Solved
I want to set up a MongoDB replica set with docker. The setup seems to be fine but I'm not able to connect to the cluster with my Java-app. I'm running Docker version 17.06.0-ce on Windows 10 with ...
Canty asked 27/12, 2017 at 21:28
© 2022 - 2024 — McMap. All rights reserved.