Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
eamonwhiter73 opened this issue Sep 19, 2018 · 0 comments

Comments

@eamonwhiter73
Copy link
Contributor

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?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant