I was tring to solve the below redis example. But I am unable to complete the step 3. Some one please help me on that. Question is:-
"city": "New Delhi",
"hotel": "Maidens Hotel",
"date": "2017-10-06",
"room_type": "single",
"occupancy": 2,
"avail_count": 13,
"booked_count": 4,
"currencyisocode": "INR",
"currency_name": "Rupee",
"provider": {
"name": "makemytrip",
"competitor_type": "partner"
},
"availroomnumbers": [ 3, 7, 23, 29, 41 ]
}
Step 1:-
Consider the above json details are unique for a particular hotel – Maidens hotel in city- New Delhi for date-2017-10-06 for single roomtype. This can be made as a hash storing multiple keys like occupancy, avail_count, booked_count,currencyisocode and currencyname with respective values. under the key roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single. Pass the values to the parameters as required
Write a command to set the above mentioned values under the key roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single
Ans:-
HMSET roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single occupancy 2 avail_count 13 booked_count 4 currencyisocode INR currency_name Rupee
Step 2:-
Add provider as another hash within the previous hash under another key roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:provider to provide the details related to provider like name and competitor_type. The provider details according to the data are
"provider": {
"name": "makemytrip",
"competitor_type": "partner"
}
Write a command to set the provider details under key roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:provider
Ans:-
HMSET roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:provider name makemytrip competitor_type partner
step 3:-
Add availroomnumbers as a set within the first hash under the key roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:availroomnumbers. Available room numbers according to the data are 3, 7, 23, 29, and 41
Write a command to set the available room numbers under key roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:availroomnumbers
Hint:-
SADD roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:availroomnumbers 3 7 29 41
3
Answers
@swapnaShubham – You need to run below command for step 3. SADD roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:availroomnumbers 3 7 23 29 41
If you are still not able to cleat then verify your test cases(you can find the expected results in score.sh file which is under Instructions tab).
For me, test cases were expecting afile called accdetails.txt. I created that file and pushed it to master and then excuted the test cases and it went through.
In Step 1 : change key name from currencyisocode to currency_iso_code
and in step 3 : add 23 to the available room numbers
Try this
HMSET roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single occupancy 2 avail_count 13 booked_count 4 currency_iso_code INR currency_name Rupee
HMSET roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:provider name makemytrip competitor_type partner
SADD roomrate:New_Delhi:Maidens_Hotel:2017-10-06:single:availroomnumbers 3 7 23 29 41