Skip to content
Advertisement

Tag: mongodb

Convert from LinkedHashMap to Json String

I’m Workin with Mongo using Jongo, when I do a query I receive a LinkedHashMap as result. the problem is that if the json is {“user”:”something”} content will be {user=something}, it is not a json is only toString method from HashMap. How I can get the original JSON? I don’t have a class to map the response and it isn’t

Mongodb avoid duplicate entries

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? Answer Use an index with the {unique:true} option. You can also do this across multiple fields. See this section in the docs for more details and

How to insert a MongoDB document with a timestamp from the database server

In Oracle, I could simply do this: That would insert two values into myTable, and one of them would be a timestamp based-on the database server’s time. For MongoDB (via the Java driver) I’ve tried this: But that creates a timestamp based-on the client machine’s time, not the database server’s time. Is there a way to have MongoDB apply a

Advertisement