Store an index for each entry with something like the following:
/wishes/$wishid/ (song, artist)
/wish_index/$hash/$wishid
Create $hash
using a hash algorithm:
var fb = new Firebase(URL);
function saveWishEntry( song, artist ) {
var wishRef = fb.child('wishes').push();
wishRef.set({
song: song, artist: artist, likes: 0
}, function(err) {
if( err ) throw err;
saveWishIndex(wishRef.name(), song, artist);
})
}
function saveWishIndex(key, song, artist) {
// http://phpjs.org/functions/md5/
var hash = MD5(song)+':'+MD5(artist);
fb.child('wish_index/'+hash).set(key);
}
Now when you want to know if a record exists, simply look it up in the index:
// callback will be passed either a {string}key or null(not found)
function wishId(song, artist, callback) {
fb.child('wish_index/'+hash).once('value', function(snap) {
callback( snap.val() );
});
}