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

  • Home
  • SEARCH
  • 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 7701009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:52:54+00:00 2026-05-31T22:52:54+00:00

I have many collections of documents in a mongo database that look like this:

  • 0

I have many collections of documents in a mongo database that look like this:

{
   "_id": ObjectId("4ee5e9079b14f74ef14ddd2f"),
   "number": 456,
   "date": "2012-02-13"
}

I need to rename the field "created_at" to "date" and I’m using Rockmongo. I think the best way to go about renaming this field would be to use the execute panel in Rockmongo. Basing my code off of this post I tried this:

function rename(x){
   db_name.coll_name.update({"_id":x._id}, {
      $rename: {"date":"created_at"}
   });
}

db_name.coll_name.find({"date":{$ne:null}}).forEach(rename);

but have been unsuccessful. I have mainly worked with pymongo (and could do it with that), but I think learning this execute panel would be very helpful as I continue to use rockmongo.

  • 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-05-31T22:52:55+00:00Added an answer on May 31, 2026 at 10:52 pm

    If you want to do all of the documents in your collection, you can do it all at once with a multi update, like so:

    db.coll_name.update({},{$rename:{"created_at":"date"}},false,true);
    

    Where “false” is the upsert option, and “true” is the multi-update option.

    Hope that helps.

    Updated with an example. It even works if the field is already partly renamed, or if the field doesn’t exist in all documents:

    > db.test2.insert({x:12});
    > db.test2.insert({x:12});
    > db.test2.insert({x:12});
    > db.test2.insert({});
    > db.test2.update({},{$rename:{"x":"x2"}},false,true);
    > db.test2.find();
    { "_id" : ObjectId("4f68afb1206dcc69f52c2157"), "x2" : 12 }
    { "_id" : ObjectId("4f68afb2206dcc69f52c2158"), "x2" : 12 }
    { "_id" : ObjectId("4f68afb2206dcc69f52c2159"), "x2" : 12 }
    { "_id" : ObjectId("4f68afb5206dcc69f52c215a") }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider I have two collections in MongoDB. One for products with documents like: {'_id':
I have a collection testcase like this, Test Builds have many Test Case Logs
We've designed our Mongo database to be highly denormalized, resulting in many documents in
I have a collection of documents that I'm attempting to parse. Like HTML, they
I have a class with many collections loaded in memory. Is it possible to
Suppose I create collection like Collection<IMyType> coll; Then I have many implelentations of IMyTypem
I have heard it many times that garbage collection in PyS60 is not up
We have an IP camera, that streams RTSP. It cannot take many connections, so
I have many different NSArray 's stored in .dat files, in the Documents folder
I have an XML document that contains a series of item nodes that look

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.