0

I need to update my MongoDB database each time from given JSON files. Is there any way to import a JSON file into MongoDB with Scala? or is it possible to execute a raw mongo command like this in Scala environment?

mongoimport --db issue --collection customer --type json --file /home/lastvalue/part-00000.json

In Java we can do like this but I need to implement it in Scala. Where I will get to import the libraries of this classes?

Bhaskar Das
  • 652
  • 1
  • 9
  • 28

1 Answers1

1

When writing Scala, you can use any Java library, including the Process library that your link refers to.

This will allow you to run the mongoimport command in a process spawned from your Scala code. If you're looking for a solution entirely written in Scala, you should use the mongo-scala-driver. The documentation includes a complete example to mimic mongoimport's functionalities.

francoisr
  • 4,407
  • 1
  • 28
  • 48