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

The Archive Base Latest Questions

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

In red is using hash, I need to store hash key with multiple fields

  • 0

In red is using hash, I need to store hash key with multiple fields and values.
I tried as below:

client.hmset("Table1", "Id", "9324324", "ReqNo", "23432", redis.print);
client.hmset("Table1", "Id", "9324325", "ReqNo", "23432", redis.print);
var arrrep = new Array();

client.hgetall("Table1", function(err, rep){
 console.log(rep);
});

Output is: { Id: '9324325', ReqNo: '23432' }

I am getting only one value. How to get all fields and values in the hash key? Kindly help me if I am wrong and let me get the code. Thanks.

  • 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-12T18:07:20+00:00Added an answer on June 12, 2026 at 6:07 pm

    You are getting one value because you override the previous value.

    client.hmset("Table1", "Id", "9324324", "ReqNo", "23432", redis.print);
    

    This adds Id, ReqNo to the Table1 hash object.

    client.hmset("Table1", "Id", "9324325", "ReqNo", "23432", redis.print);
    

    This overrides Id and ReqNo for the Table1 hash object. At this point, you only have two fields in the hash.

    Actually, your problem comes form the fact you are trying to map a relational database model to Redis. You should not. With Redis, it is better to think in term of data structures and access paths.

    You need to store one hash object per record. For instance:

    HMSET Id:9324324 ReqNo 23432 ... and some other properties ...
    HMSET Id:9324325 ReqNo 23432 ... and some other properties ...
    

    Then, you can use a set to store the IDs:

    SADD Table1 9324324 9324325
    

    Finally to retrieve the ReqNo data associated to the Table1 collection:

    SORT Table1 BY NOSORT GET # GET Id:*->ReqNo
    

    If you want to also search for all the IDs which are associated to a given ReqNo, then you need another structure to support this access path:

    SADD ReqNo:23432 9324324 9324325
    

    So you can get the list of IDs for record 23432 by using:

    SMEMBERS ReqNo:23432
    

    In other words, do not try to transpose a relational model: just create your own data structures supporting your use cases.

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

Sidebar

Related Questions

Using the code below I'm expecting a green rectangle and a red one of
I need to detect all the red pixels in an image using Java. What
I'm using red hat 5 linux, and I would like to know what key
I was trying to use the function glMultiDrawElements while studying OpenGL (using red book)
I'm using VIM in red hat 5, with the black background and green letters.
I am using Tomcat 6.0 and getting the same red underline saying Can not
Using jquery, how can I change the color of these elements to red if
Getting red warning message that expected identifier for this statement CALayer = ImageView.layer; Using
Why does every row have a red background when I'm using nth-child(odd) ? <div
I using following code: var search = 'test'; if ($('#sku').find(search) ){ //alert(search); $(document).find(search).css('color','red'); <TABLE>

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.