Skip to content

request to add createSubcollectionWithDocument and deleteDocumentFromSubcollection (or is there already a way to do this?) #3

Description

@eamonwhiter73

I am trying to create a document in a subcollection, and then delete a document in a subcollection - is there a way I can accomplish this with the functions available? Otherwise, I would like to add:

js:

createSubcollectionWithDocument(db, collectionName, docId, collectionNameTwo, docIdTwo, data) {
        db.collection(collectionName).doc(docId).collection(collectionNameTwo).doc(docIdTwo).set(data)
            .then(res => console.log(`${JSON.stringify(data)} is added to ${collectionNameTwo} collection`))
            .catch(err => console.log('Error: ', err));
    }

deleteDocumentFromSubcollection(db, collectionName, docId, collectionNameTwo, docIdTwo) {
        db.collection(collectionName).doc(docId).collection(collectionNameTwo).doc(docIdTwo).delete()
            .then(() => {
            console.log(`${docIdTwo} successfully deleted!`);
        }).catch(error => {
            console.error("Error removing document: ", error);
        });
    }

ts:

createSubcollectionWithDocument (db: any, collectionName: string, docId: string, , collectionNameTwo: string, docIdTwo: string, data: Object): void {
        db.collection(collectionName).doc(docId).collection(collectionNameTwo).doc(docIdTwo)).set(data)
            .then(res => console.log(`${JSON.stringify(data)} is added to ${collectionNameTwo} collection`))
            .catch(err => console.log('Error: ', err))
    }

deleteDocumentFromSubcollection (db: any, collectionName: string, docId: string, collectionNameTwo: string, docIdTwo: string) {
        db.collection(collectionName).doc(docId).collection(collectionNameTwo).doc(docIdTwo).delete()
            .then(() => {
                console.log(`${docIdTwo} successfully deleted!`);
            }).catch(error => {
                console.error("Error removing document: ", error);
            });
    }

I've actually never gone about editing a package. if you can provide the steps that would be helpful (i think maybe requesting a pull? and then commiting...to master?)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions