Search code examples
rubymongodbmongoid

What is the difference between the two versions of mongoid first_or_create


I was going over mongoid documentation https://mongoid.github.io/old/en/mongoid/docs/querying.html

and it is not clear to me what is difference between first_or_create & first_or_create!

Can someone help me understand ?


Solution

  • I think you could take a look at

    https://mongoid.github.io/old/en/mongoid/docs/persistence.html

    create = Insert a document or multiple documents into the database

    create! = Insert a document or multiple documents into the database, raising an error if a validation error occurs.