Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete by Id in mongoid

Is there any one command in Mongoid to delete an object using id?

Something like,

ClassName.delete(:id)

Currently i dont see anything like that and im using,

obj = ClassName.find(:id)
obj.delete

Can it be any better?

like image 743
Prasanna Avatar asked Dec 30 '25 01:12

Prasanna


1 Answers

Another Way

ClassName.any_in(:_id => ["id1", "id2"]).destroy_all
like image 158
Jyothu Avatar answered Dec 31 '25 19:12

Jyothu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!