Skip to content

Instantly share code, notes, and snippets.

@yimengtianya
Created October 13, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save yimengtianya/6bb23ec1b220c7e8c790 to your computer and use it in GitHub Desktop.
Save yimengtianya/6bb23ec1b220c7e8c790 to your computer and use it in GitHub Desktop.
Wilddog: 得到父引用快照.
function getParent(snapshot) {
// You can get the reference (A Wilddog object) from a snapshot
// using .ref().
var ref = snapshot.ref();
// Now simply find the parent and return the name.
return ref.parent().name();
}
var testRef = new Wilddog("https://example.wilddogio.com/foo/bar");
testRef.once("value", function(snapshot) {
// Should alert "Name of the parent: foo".
alert("Name of the parent: " + getParent(snapshot));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment