Skip to content

Instantly share code, notes, and snippets.

@amark
Created November 8, 2015 23:36
Show Gist options
  • Save amark/c5b99f3fca9bcab17f33 to your computer and use it in GitHub Desktop.
Save amark/c5b99f3fca9bcab17f33 to your computer and use it in GitHub Desktop.
<html>
<body>
<script src="http://rawgit.com/amark/gun/master/gun.js"></script>
<script>
localStorage.clear();
var gun = Gun();
// define the snake team!
var snakes = gun.get('team/snakes').put({team: "snakes"});
// add members to the snake team in one go!
snakes.path('members')
.set({name: "alice"}).back
.set({name: "bob"}).back
snakes.val(function(theTeam){
// now add the snake team as a field to each of the members.
snakes.path('members').map(function(){
this.path('team').put(theTeam);
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment