var stallone = {stallone:{first:'Sylvester',last:'Stallone',gender:'male'}};
var gibson = {gibson:{first:'Mel',last:'Gibson',gender:'male'}};
var movies = gun.get('movies')
movies.put(stallone).key('movies/action').key('movies/actors').key('movies/action/rambo') movies.put(gibson).key('movies/action').key('movies/actors').key('movies/action/roadwarrior').key('movies/comedy');
movies.get('movies/action').val();
returns {_: Object, stallone: Object, gibson: Object} Nice.
movies.get('movies/comedy').val();
returns {_: Object, stallone: Object, gibson: Object} Erm..What is Sly doing here? Not Nice!!
gun.get('movies/comedy').val();
returns {_: Object, stallone: Object, gibson: Object} same thing!!
This behaviour leads to a couple of questions:
1) why bother creating movies ?
I'm working with var movies = gun.get('movies')
so why do i have to create the key with 'movies'
in it again? 'movies' should be prefixed automaticly.
2) Even if the multiple keys would work it's not very intuitive. It would be nice if we could just do
movies.put(gibson).keys(['actors','comedy','action'])
.
Note: i would be happy if could be done tru a loop. but that doesn't work eather
var gibsonKeys = ['actors','action','comedy','dieHard']
gibsonKeys.forEach(function(key){
movies.put(gibson).key('movies/'+key);
// could be gun.put(gibson).key('movies/'+ key) as well
});
As a sidenote...I know that the keys are just strings and not real paths to the data ;)