How To Angularfire2 Remove() By Some Key Value
I am trying to delete comments of a particular thread orderby some key(sid) value. eComments 0b4080bb4e686f003aaa340f8ed2e2a6 cid: '0b4080bb4e686f003aaa340f8ed2e2a6' comment
Solution 1:
This is one way:
const commentList = this.af.database.list('/eComments', {
preserveSnapshot: true,
query: {
orderByChild: 'sid',
equalTo: sid
}
});
commentList.subscribe(snapshots=>{
snapshots.forEach(snapshot => {
snapshot.ref.remove();
});
})
I am not an AngularFire2 expert, so there might be easier/more idiomatic ways.
Post a Comment for "How To Angularfire2 Remove() By Some Key Value"