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?

1
  • 1
    What have you tried by yourself? Commented Aug 19, 2018 at 23:53

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.