Skip to content

Instantly share code, notes, and snippets.

@anantn
Last active February 19, 2019 23:45
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save anantn/4325082 to your computer and use it in GitHub Desktop.
Save anantn/4325082 to your computer and use it in GitHub Desktop.
Firebase: Removing an item you've pushed. This snippet shows how to remove an object that you just added using push().
function pushSomething(ref) {
// Let's push something. push() returns a reference that you can hold onto!
var justPushed = ref.push({test: "push"});
// We return a reference, but you can also return the name of the newly
// created object with .name().
return justPushed;
}
function removeItem(ref) {
// Now we can get back to that item we just pushed via .child().
ref.remove(function(error) {
alert(error ? "Uh oh!" : "Success!");
});
}
function go() {
var testRef = new Firebase("https://example.firebaseIO.com/");
var newRef = pushSomething(testRef);
// Later... should popup an alert that says "null" (No Error).
removeItem(newRef);
}
@ctmcquilkin
Copy link

Nevermind. I created a little demo that helped me with this: https://gist.github.com/ctmcquilkin/6722983

Thanks!

@pkill9
Copy link

pkill9 commented Apr 17, 2014

Add an android example as well

@guibot17
Copy link

Hey

@taigeair
Copy link

Thanks!

@nishasinghdx
Copy link

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment