( Gun.version 0.9.6 )
给定以下数据结构
{
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
}
}
}
}
我想同时开/关灯。
gun.get('lights').val(cb)
确实给了我 {1:{...},2:{...},3:{...}} 并且gun.get('lights').path('1.state.on').put(false);
效果很好。
我认为这样做gun.get('lights').map().path('1.state.on').put(false)
会“映射”所有灯光,但它只会改变第一盏灯。
问题:如何打开/关闭所有灯?