Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:32:46+00:00 2026-06-10T21:32:46+00:00

We are currently migrating from MySQL to MongoDB, and I stumbled over the following:

  • 0

We are currently migrating from MySQL to MongoDB, and I stumbled over the following:

MyModel.destroy(params[model_ids]) # Remove many objects at once by passing an array of IDs

This worked for ActiveRecord, but for MongoDB it doesn’t: I have to iterate over the IDs, find it, and then call the delete method on the instantiated object:

MyModel.find(params[model_ids]).each do |item|
  item.destroy
end

Is this the correct way to go? And is there a special reason why Mongoid doesn’t offer the mentioned functionality?

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:32:48+00:00Added an answer on June 10, 2026 at 9:32 pm

    You can try this

    MyModel.where(:_id.in => params[model_ids]).destroy
    

    In Mongoid you can run the destroy method on a criteria.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently migrating from WinForms over to WPF and I'm really struggling with the
I'm in the process of migrating my application's database from MySQL to NoSQL(MongoDB). However,
I'm currently migrating my project from Hibernate HBM Mappings to Annotations. Everything was easy
I'm currently working on migrating an application from MS-Access to MS SQL Server. In
We are currently migrating from PHP4 to PHP5 and have discovered an issue. In
Currently we are migrating from Delphi 2007 to Delphi XE2 to support Unicode .
Im currently looking at migrating from fluent nHibernate to ADO.Net Entity Framework 4. I
We are currently migrating a WCF service from IIS 6 to IIS 7. The
We are currently considering the option of migrating from svn to git for all
We are currently evaluating options for migrating from hand-written persistence layer to ORM. We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.