I'd like to remove a document from Firebase sub-collection. I'm trying to do this in the following way:
firestore.collection('categories').doc(categoryId).collection('books').doc(bookId).delete();
And it doesn't work.
However, I'm able to remove a document from the collection:
firestore.collection('categories').doc(categoryId).delete();
Am I losing sight of something? How should it work?
UPDATED:
const firebase = require('../firebase/firebaseAdmin');
const firestore = firebase.firestore();
module.exports = {
removeBookFromCategory: (categoryId, bookId) => (
firestore
.collection('categories')
.doc(categoryId)
.collection('books')
.doc(bookId)
.delete()
),
};
I have correct ids here but I'm getting 500 error:
Error: Argument "documentPath" is not a valid ResourcePath. Path must be a non-empty string.