Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

ctmcquilkin commented Sep 26, 2013

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

Thanks!

@pkill9

This comment has been minimized.

pkill9 commented Apr 17, 2014

Add an android example as well

@guibot17

This comment has been minimized.

guibot17 commented Sep 15, 2015

Hey

@taigeair

This comment has been minimized.

taigeair commented Mar 23, 2016

Thanks!

@nishasinghdx

This comment has been minimized.

nishasinghdx commented Jun 21, 2018

thanks

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