Anan Kassis
Anan Kassis

Reputation: 46

Firebase Delete Function not working correctly

Some Strange thing is hapenning ..

I Am trying to delete document from firebase, the problem is even when the ID, isn't found on the collection It gives me back , a successfull msg.

is it a bug on firebase ???

DeleteOrganization(id) {
    return this.afs.collection('organizations').doc(id).delete()
      .then( () => {
        console.log('Document successfully deleted!');
      }).catch( (error) => {
        console.error('Error removing document: ', error);
      });
  }

Upvotes: 0

Views: 1752

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317868

The delete method gives you confirmation that a document doesn't exist. The document doesn't have to exist ahead of time.

If you need to ensure that a document exists before you delete it, you should check for that yourself, though I don't think you have anything to gain from that (it is just extra work for the same end result).

Upvotes: 2

Related Questions