1

i was able to upload and fetch data from firestore but the issue is deleting the data collected. Below is my code My services

 delete_AcBooking(record_id) { return this.afirestore.doc(`users/${this.user.getUID()}/AcBooking` + record_id).delete(); } 

component.ts

 RemoveRecord(rowID) { this.bookingservice.delete_AcBooking(rowID); } 

error

ERROR FirebaseError: Invalid document reference. Document references must have an even number of segments, but users/pht1VUEXbFfkD3udB9Q3cMwWtcH2/AcBookingLHF9Yj9JkoFpaUOsJtpd has 3 at new FirestoreError (http://localhost:4200/vendor.js:85176:28) at Function.push../node_modules/@firebase/firestore/dist/index.cjs.js.DocumentReference.forPath (http://localhost:4200/vendor.js:105305:19) at Firestore.push../node_modules/@firebase/firestore/dist/index.cjs.js.Firestore.doc (http://localhost:4200/vendor.js:105091:34) at AngularFirestore.push../node_modules/@angular/fire/firestore/firestore.js.AngularFirestore.doc (http://localhost:4200/vendor.js:67496:34) at BookingServiceService.push../src/app/service/booking-service.service.ts.BookingServiceService.delete_AcBooking (http://localhost:4200/main.js:5076:25) at BookingsPage.push../src/app/pages/bookings/bookings.page.ts.BookingsPage.RemoveRecord (http://localhost:4200/pages-bookings-bookings-module.js:333:29) at Object.eval [as handleEvent] (ng:///BookingsPageModule/BookingsPage.ngfactory.js:44:31) at handleEvent (http://localhost:4200/vendor.js:65419:41) at callWithDebugContext (http://localhost:4200/vendor.js:66489:25) at Object.debugHandleEvent [as handleEvent] (http://localhost:4200/vendor.js:66216:12) 
1
  • Side note: have you read the docs about deleting? There are a number of complications with deleting sets of data and it's not recommended to do it on the client side. docs Commented Aug 5, 2019 at 7:05

1 Answer 1

2

You seem to be missing some /. Try following:

this.afirestore.doc(`users/${this.user.getUID()}/AcBooking/${record_id}`).delete(); 

or do:

return this.afirestore .collection('users') .doc(this.user.getUID()) .collection('AcBooking') .doc(record_id) .delete() 

Here I assume AcBooking is a collection.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.