2017-10-18 4 views
-1

해시 내부의 키가 존재하는지 (redis) 어떻게 확인합니까? 해시 내부의 키가 존재하는지 (redis) 어떻게 확인합니까?

redisClient.exists(obj.mydict.user.toString().pos, function(err,reply) { 
       if(!err) { 
        if(reply !== null) { 
        ... 

그러나 내가 얻을 :

node_redis: Deprecated: The EXISTS command contains a "undefined" argument. 
This is converted to a "undefined" string now and will return an error from v.3.0 on. 
Please handle this in your code to make sure everything works as you intended it to. 

내가 방법을 모르는

나는이 방법을 시도했다. 내가 뭘 하려는지 내 .pos 키가 내 해시에 존재하는지 확인하는 것입니다 obj.mydict.user.toString(), 어떻게 할 것입니까 node_redis?

답변

1

어떻게 사용하나요? 레디 스 해시에 필드의 존재를 확인하기 위해 특정 명령은 없지만

var hash = {'a': 1, 'b': 2}; 
console.log('a' in hash); 
console.log('c' in hash); 
+0

그래서 이렇게했는데, 그 다음에 redis에서 모든 해시를 검색해야합니다. 은행에 키가 있는지 확인하고 싶습니다. – PerduGames

+0

내가 여기에있는 문서에서 보았던 것 같습니다. 그래서 방법은 :'redisClient.hgetall (obj.mydict.user.toString(), function (err, reply) {if (! err) {if ("pos"in reply) {...} – PerduGames

2

, 당신은 HGET를 호출하고 nil 응답에서 비 존재를 추론 할 수 있습니다.