I have data on Riak DB in the format like:
Bakshi - {u'friendlist': [u'Sita', u' Hari', u' Shyam', u' Howard', u' Bindu', u' Kishna', u' Karma', u' Dinesh'], u'is_active': True, u'user': u'Bakshi'}
Here fethcing Data Via Map/Reduce
client = riak.RiakClient()
user_bucket = client.add('userfriendlist')
user_bucket.map("""
function(v){
var data = JSON.parse(v.values[0].data);
if(data.is_active == true){
tempUser = data.user;
tempFriendlist = data.friendlist;
for (var i=0; i<tempFriendlist.length; i++){
friendValue = tempFriendlist[i];
return [[tempUser,friendValue]];
}
}
}
""")
and print the return value
for result in user_bucket.run():
print "%s - %s" % (result[0],result[1]);
It gives the output like:
Bakshi - Sita
But the expected outpt is:
Bakshi - Sita
Bakshi- Hari
Bakshi- Shyam
Bakshi- Howard
Bakshi- Bindu
Bakshi- Kishna
Bakshi- Karma
Bakshi- Dinesh
what i am doing wrong here, I cannot do iteration inside map()?