Suppose I have a SQL table that contains an field called userid (unique,Primary key, autoincrement), Username (varchar), and password (Varchar).
Now suppose I want to recreate this table in Redis. From my understanding, it's best to use a "hash" for this table. Thus my node.js code has a function that creates a user:
function newUser(username,password)
{
//incr the userid
client.incr("userid",redis.print);
//Creating the user
client.get('userid',function(err,userid){
client.hmset("users", "id",userid,"name",username,"password",password);
});
}
Is this correct?
Also, how do I access the information stored in his hash? I try the following but am only able to return 1 row:
client.hgetall('users',function(err,user){
console.log('User Name: ' + user.name +" password = "+user.password);
})
Lastly, how would I join 2 hashes (like I would for 2 tables that needed to be joined?)