0

I am working on a spring boot project which uses spring data mongodb. Spring data mongodb auto creates the db and collection when it doesn't exists. I want to disable auto creation of db and collection in mongodb when it doesn't exists.

How to achieve that? Is there any property which can be used?

4
  • 2
    The spring boot mongodb library does not have this kind of behaviour. The collections are not created unless a document has been insert or it has explicitly told to do so. What library are you using for mongodb? Do you have any inserts on startup? Commented Jul 5, 2022 at 10:45
  • When i am inserting any document, it creates the collection. Is there a way to disable that behaviour? Commented Jul 6, 2022 at 12:46
  • I am using spring-boot-starter-data-mongodb Commented Jul 6, 2022 at 12:47
  • Sorry then I'm not understanding, how can a document be insert in a collection and the collection not being created. Are you inserting a document in collection x and it creates collections x and y or is it creating only collection x? Cause if it's the latter then it's the expected behaviour and there is no way to disable that Commented Jul 12, 2022 at 12:38

0

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.