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 8660709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:19:24+00:00 2026-06-12T16:19:24+00:00

I have a MongoDB (v2.2.0) collection that contains reference data. Periodically, I need to

  • 0

I have a MongoDB (v2.2.0) collection that contains “reference data”. Periodically, I need to replace all the documents in that collection with data from an outside source. It’s important that nothing accesses the collection while the reference data is being replaced.

Am I correct in thinking the best solution to simply create a new (i.e., “temporary”) collection with a different name, load it with data, then rename it?

For example:

  1. Create collection myCollection-TEMP
  2. Insert all documents into myCollection-TEMP
  3. Rename the temp collection to replace (i.e., drop prior to the rename) the current collection db.myCollection-TEMP.renameCollection('myCollection', true)

From what I can tell, there’s no way to safely “empty” a collection, do a “bulk import” of documents, and ensure nothing else accesses the collection in the middle of that process.

  • 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-12T16:19:26+00:00Added an answer on June 12, 2026 at 4:19 pm

    Yes, creating a temp collection and then renaming is the way to go. This is a common approach in other technologies as well. For example, double buffering in computer graphics. You prepare a frame in an invisible background plane and then just swap it with the screen. This instantly updates the picture without flicker or other artifacts.

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

Sidebar

Related Questions

Let's assume that I have a collection in mongodb, where all of its documents
I have a MongoDB collection with data that was not saved through my Derby
I have 10000 documents in one MongoDB collection. I'd like to update all the
I have an applicaton written in PHP that retrieves files from mongoDB Grid collection,
Resulting from a MapReduce, I have a MongoDb collection that has the following structure:
i have a mongoDB collection named col that has documents that look like this
I have a collection of articles in MongoDB that has the following structure: {
I have mongodb running and using morphia. Having a Collection of BatchData Documents and
In MongoDB I have a collection of documents called 'clients', where each document is
I have a collection where I only ever need to look up documents by

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.