I have a client facing application with a function that takes in 2 arguments as strings, arg1 is the collection, arg 2 is the function, arg 2 is the hash of the object
so in Java I have
foo(String collection, String object):
/*and I have my db object from the mongoDB driver the collection I want to insert into is "users" */
MongoClient mongoClient = new MongoClient( "localhost" );
DB db = mongoClient.getDB("mydb");
now here is where I am having trouble
db.runCommand({insert : collection (? can i do this),
????}) <- I dont know how to right this and append the object
I did a bunch of searching before hand and a lot of the examples I found already had a predefined collection but I need to abstract this.
Any help would be extremely useful, thank you.
UPDATE:
I am not looking for coll.find() java method. I want to visualize someones mongoDB data with a better output than what the shell provides. So I am looking for a very general db.runcommand(string) that can take in an insert/find/findone() whatever is passed in as a string. I can get collection names using runcommand so I understand it on a basic level, but cannot apply specific commands to any user defined collection.