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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:58:54+00:00 2026-06-12T14:58:54+00:00

In my playing with Mongodb over the past few weeks I am developing more

  • 0

In my playing with Mongodb over the past few weeks I am developing more and more complex applications, in my latest project i would like to insert a key:value into an object. I am using mongojs & node.js.

I am generating a dynamic key (ie: hash = 3gx83h7) for my new key:value to be pushed into the object paths. I know I can do the following:

db.applications.update({'apikey':key,'uid':user._id}, {'$set':{'paths.hash':0}},function(err){
    if(!err){}
});

But that will push a key:value similar to this:

paths:{
    hash:0
}

How can i push in my generated hash as the key?

  • 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-12T14:58:56+00:00Added an answer on June 12, 2026 at 2:58 pm

    You need to assemble the key name programmatically so that hash‘s value is used:

    var setValue = {};
    setValue['paths.' + hash] = 0;
    
    db.applications.update(
        {'apikey': key, 'uid': user._id}, 
        {'$set': setValue}, 
        function(err){
            if(!err){}
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently been playing with nodejs and would like to build my first project
I've been playing around storing tweets inside mongodb, each object looks like this: {
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
I was playing around with mongodb on PHP and I noticed something strange, look
Playing with Erlang, I've got a process-looping function like: process_loop(...A long list of parameters
I am playing with MongoDB since yesterday and absolutely love it. I am trying
Playing with a few tutorials on sockets but struggling to connect. My tomcat server
Playing with URLs, more specifically building them incrementally from other, discovered URLs. In doing
Whilst playing around in an open source project, my attempt to ToString a DateTime
I have been playing with mongodb for a while. I dont get the concept

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.