Created
November 8, 2015 23:36
-
-
Save amark/c5b99f3fca9bcab17f33 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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