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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:42:43+00:00 2026-05-26T12:42:43+00:00

I use MongoDB in one of my Java projects. After a DB schema change,

  • 0

I use MongoDB in one of my Java projects. After a DB schema change, I found myself modifying existing code at a lot of places to perform the change from e.g.:

Object result = collection.findOne();

to

Object result = collection.findOne().get("ThisField").get("ThatField");

Now, things are relatively simple in the findOne() case, but they get more complex when find() and the associated cursors come to play.

In most cases, it would have been far easier if I could modify the query, rather than its result. I have already experimented with retrieving specfic fields only, but as far as I can tell, that only masks the rest of the fields – it does not change the structure of the object.

  • Is it possible to specify a query so that the objects that form the values of a specific field are “promoted” to a top-level object, thus removing the .get("this").get("that") calls?

  • As a further step, does MongoDB support any equivalent to the views, as seen in conventional databases? Something that might allow existing code to continue working in case of a schema change?

  • 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-26T12:42:44+00:00Added an answer on May 26, 2026 at 12:42 pm

    It seems that MongoDB does not currently have any server-side equivalent of the relational database views. The MongoDB Map/Reduce support is apparently suitable only for batch operations, which makes it useless for an online database with real-time updates.

    As a workaround, I turned to a client-side solution. I took advantage of the fact that the Java driver is open source and thus I could easily work out how it is structured.

    More specifically, I was able to extend and replace the default BSON decoder for the collections of interest and transparently relocate the fields that had moved.

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

Sidebar

Related Questions

I wish to use MongoDB in one of my projects created with asp.net and
We have a lot of data, decided to use mongodb and it works great.
During working on one c++ project we decided to use MongoDB database for storing
I've been looking around a lot to see how to use MongoDB in combination
I have a good reason to use MongoDB for part of my app. But
Is it a good idea to use MongoDB in .NET desktop application?
'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move
use this website a lot but first time posting. My program creates a number
I'm in the process of converting my Rails app to use mongodb through mongoid.
I'm using MongoDB to store user profiles, and now I want to use GridFS

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.