( Gun.version 0.9.6 )
Given the following data structure
{
lights:{
1:{
state:{
on:true,
color:'red',
br:254
}
},
2:{
state:{
on:true,
color:'red',
br:254
}
},
3:{
state:{
on:true,
color:'red',
br:254
}
}
}
}
I want to turn the lights on/off at the same time.
gun.get('lights').val(cb)
does give me {1:{...},2:{...},3:{...}} and gun.get('lights').path('1.state.on').put(false);
works perfect.
I thought that by doing gun.get('lights').map().path('1.state.on').put(false)
it would 'map' over all lights but instead it only changes the first light.
Question: How do i turn on/off all the lights ?
@stef-de-vries , you've spotted an important TODO bug in gun's source code!
Currently (v0.9.6),
put
does not work withmap()
commands. I think it only picks the first item (which may be random) and then turns it off.This is bad, and needs to be addressed.
For now, the work around is to probably do something like:
Which is ugly.