how can i create a mongodb database from java

I can drop a database with the following statement: MongoClient mongo = new MongoClient("localhost", 27017); mongo.dropDatabase("d"); How can I create a database? MongoClient mongoClient = new MongoClient(); DB db = mongoClient.getDB(&

MongoDB drop-down 2 bays incorporated separately

I have a question regarding MongoDB aggregation query which is almost similar to $unwind 2 fields separately in mongodb query. This is the document: { "_id" : "1", "details" : { "phonenumber" : [ "1", &quo

Grails 2.5.0 + mongo + hibernate

I am trying to use hibernate with mongo driver and experiencing some issues: I have created brand new grails app, using grails 2.5.0. changed dataSource.groovy to point to mysql, uncommented mysql-connector-java:5.1.29 and everything works fine. But

Could not find subfield

I have this data on my mongodb database: { "_id" : BinData(3, "bU0bX4VEAMnW7AJ28wXcoA=="), "online" : false, "money" : 0, "rank" : "USER", "ban" : { "end" : NumberLong("3

Create a dynamically mongodb query

I have a collection, say, test which contains some 100 fields like _1, _2, _3 etc Now I want to form MongoDB query such that whatever input comes like 1, 2, 5 or 5, 6, 7, 8, 9. A proper query can be generated. Please help with respect to MongoJack.Tr

Meteor: Showing Separate Documents by Days

I've got a MongoDB where each row has a datetime and a name. I want a selection of them, let's say every row since the 9th, but I also want to display them with a seperator for each day like: TODAY: -First -Second IN 3 DAYS -Third -Fourth So i figure

Using the aggregate on documents that contain tables?

I have a collection that contains documents with a structure like below: { answers: [ { Title: 'What's your age?', values: [ {value: true, label: '18-30'} ] }, { Title: 'What's your favorite color(s)?', values: [ {value: true, label: 'Red'}, {value:

Mongodb datetime insertion

I am newer in mongoDb trying to insert current date time using Java program. I am using joda library to to format the date into ISOdate format and want to store the current date and time as it is.But after doing insertion it is showing 1 hour delay t

Where is the hassed session key of the express.session store?

I am using mongoStore to manage session on express.js framework. ... var MongoStore = require('connect-mongo')(express); ... ... app.use(express.session({ secret:settings.cookieSecret, store: new MongoStore({db:settings.db}) })); ... but here is the

MongoDB signal to the application

Short question: Can MongoDB contact application if something is changed in collection? Some kind of trigger which will signal application that some field is changed or added or something like that?If you can leverage the spring-data-mongodb then you

Mongodb disk space

We a one collection in which every document have average 16 KB size, and document count is 30,000, that's mean total space should be (30,000 * 16) / 1024 * 2024 = 1.71 GB but we found size of collection in collection stats is 28.6 GB, its horrible. C

Effective cronjob recommendation

Brief overview about my usecase: Consider a database (most probably mongodb) having a million entries. The value for each entry needs to be updated everyday by calling an API. How to design such a cronjob? I know Facebook does something similar. The

Queries in MongoDB

I'm trying to use rmongodb to fetch information from a MongoDB database for further processing in R. However, I have some difficulties to really get started. This one works: cursor <- mongo.find(mongo, "people", query=list("Smi

mongodb can not boot on Windows?

when i tried to start mongodb using the command "mongod.exe" on the command line, it throws the following error.. C:\mongodb-win32-x86_64-2.0.6\bin>mongod.exe mongod.exe --help for help and startup options Thu Aug 09 11:56:48 [initandlisten]

Get DateTime from the mongo collection using the C # driver

I have the following object: public class QueueItem { public long _id { get; set; } public SiteMapRequestState State { get; set; } public int WorkerId { get; set; } public DateTime QueuedTime { get; set; } public DateTime StartWorkTime { get; set; }

sum of more than one field in mongoid

Lets say class User include Mongoid::Document field :sign_in_count, :type => Integer, :default => 0 field :some_other_count, :type => Integer, :default => 0 end I need to get a Hash that will consist of sum of both fields So the result will lo

Can not connect to MongoDB / weird

I installed mongoDB through the official tutorial The daemon starts up, a netstat-na | grep 27017 shows: tcp 0 0 * LISTEN unix 2 [ACC] STREAM LISTENING 100949 / tmp/mongodb

Strategies for real-time aggregations in MongoDB

In exploring ways to do real-time analytics with MongoDB, there seems to be a fairly standard way to do sums, but nothing in terms of more complex aggregation. Some things that have helped... Twitter's Rainbird: Realtime sums, incrementing counters o

MongoDB - mongohub mistlet - queries by _id type objectid

I am using MongoHub GUI for MongoDB: I would like to be able to query by ObjectId as this is what MongoHub is returing for _id. How to do this, something like {"_id":"4d1b4687a6d5437619000000"} is not wo

MongoDB or CouchDB as a database for mobile devices?

I wonder if MongoDB and CouchDB could work as database for mobile devices? If they both can, which one is better to use for online/offline storage?CouchDB has built in support for offline synchronization. It would we be a better fit.