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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:51:31+00:00 2026-05-24T06:51:31+00:00

Is there any way to modify the mongo values in a where-clause in a

  • 0

Is there any way to modify the mongo values in a where-clause in a find query?

This is the one I use right now:

$db->users->findOne(array("redirect_uri" => $arrParsedUrl['host']));
  • In this case I need to make sure that the value earlier inserted into the database is only the host part of the URL.

What I would like to do is someting like this (but it’s not working):

$db->users->findOne(array(parse_url("redirect_uri")['host'] => $arrParsedUrl['host']));
  • In this case I would be able to insert the complete URL in the database from the beginning. The “parse_url” function in the query makes sure that only the host part is actually compared.

Any ideas how to achive something similar?

Edit:
I don’t want to update the values in the database. Only modify the value from the database used in the where-clause that is compared to the input value.

The input value will always be the host part of an URL.

Edit2:

  1. I have several documents in a collection called users.
  2. All documents have a field called “redirect_uri” that contains an URL.
  3. When I call a php function with an url as input I would like to return the document where the host part of the input URL is the same as the host part of the “redirect_uri” in the document.
    E.g. http://www.foo.com/bananas (“redirect_url”) = http://www.foo.com/apples (input URL)
  4. How can I query MongoDB to get the document where the host part of the “redirect_url” is the same as the host part of the input URL? To modify the input URL to http://www.foo.com is not a problem but how do I modify the “redirect_url” part in the same way to make the query give me a correct answer?
  • 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-24T06:51:32+00:00Added an answer on May 24, 2026 at 6:51 am

    Your question is a bit ambiguous, you are either looking for update (this one just updates):

    db.collection.update( criteria, objNew, upsert, multi );
    

    or findAndModify (this one updates and retrieves)

    Edit:

    Just do the transformation on the client side. The mongoDB philosophy is to push as much work to the clients as possible.e

    Edit2:

    • You can use regular expressions.
    • You can restructure your database to store the host in a separate field.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way to modify the bound value of one of the variables
Is there any way to modify the CSS properties of one table's cells based
In git, is there any (simple) way to modify the index so that only
Is there any way to MODIFY ( NOT replace) a middleware in rails? So
Is there any way to modify the generic Android Exception message The application ...
is there a way to modify the values of a status field in the
I'm using Visual Studio 2010 + ReSharper. I there any way to modify auto-indent
Hello I would like to know, if there is any way to dynamicaly modify
is there any way to modify Javadocs @version value and add revision number of
Is there any way I can modify some style to all elements that matches

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.