如何删除 Firebase JavaScript 中最早的 child?

How to delete the oldest child in Firebase JavaScript?

我想通过在每次添加新列表时删除最旧的 child 来限制我的 Firebase 应用程序中的数据量。我怎样才能做到这一点?

所以每次添加 child 时,您想从同一个列表中删除最早的 child?

var ref = new Firebase('https://your.firebaseio.com/children');
ref.on('child_added', function(newSnapshot) {
  ref.limitToLast(1).once('child_added', function(oldestSnapshot) {
    oldestSnapshot.ref().remove();
  });
});