Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

MongoDb Create Collection By Json  RSS feed

v sasd
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have to use MongoDb but for me is my first time. Can you help me? Thanks very much.
I have a Json like this, and on this structure i have to create a collection if it not exist already otherwise update it:

Now to be clear.

IMEI must be the collection name.

EVENTS array must be the collection elements.

So step by step i need:

1. Check if exist a collection IMEI;
2. If not exist this IMEI collection create it;
3. Insert EVENTS elements in IMEI collection.

Is there a way to do this by command line or using an any programming language?

Thanks to all.
chris webster
Posts: 2407
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch!

MongoDB has driver APIs for most major programming languages e.g. Java, Python, so you can start writing programs with your preferred programming language. If you know a bit of Python, I would recommend starting there, as the Python API is much easier to use than Java.

MongoDB also has an interactive JavaScript shell which allows you to manipulate your data via the command-line: This is a good way to get started with MongoDB and it's great for trying things out, but it's not suitable for application development.

you should be able to figure out how to perform each of the steps in your process using one of these APIs e.g. try it in the shell first, then look for the corresponding commands in your chosen drive API.

There are lots of other tools around MongoDB e.g. for import/export, database administration etc. These are generally well documented on the MongoDB website where you will find the MongoDB manual and various tutorials.

MongoDB university also runs regular free online courses in MongoDB for developers or database administrators. These run for around 7 weeks and are well worth doing if you have a chance as the developer courses cover a lot of ground, explaining how MongoDB works, how it stores data, how to program MongoDB applications, etc.

If you are using MongoDB at work, then hopefully your colleagues will also be able to advise you on how to get started with MongoDB.

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!