-
Notifications
You must be signed in to change notification settings - Fork 112
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
Extracting collection/document path from document name #99
Comments
I'm not sure I'm following accurately... Can you provide an example name and walk through the problem? We have |
For example if I have a collection of documents and I want to update a common property, calling const docs = fs.getDocuments("collection");
docs.forEach(doc => fs.updateDocument(doc.name, { "key": "newVal" }, true)); throws an error saying |
Oh, I get it. Wouldn't you be able to do: const collectionPath = "collection";
const docs = fs.getDocuments(collectionPath);
docs.forEach(doc => fs.updateDocument(`${collectionPath}/${doc.name}`, { "key": "newVal" }, true)); to accomplish the same without the extraction process? |
That would create a completely new collection hierarchy under |
Ok, I'll be adding a property to the docs.forEach(doc => {
const name = doc.name.match(/^projects\/.+?\/databases\/\(default\)\/documents\/(.+\/.+)$/)[1];
fs.updateDocument(name, { "key": "newVal" }, true));
}); Where the RegEx is from |
Update Tests to sync with Shields and Github caching. Fix Tests that couldn't fail. Update README and packages.
I often find myself in a situation where I have a Firestore document that I want to update or delete, but no other reference to the collection/name than Document.name, which doesn't work as is, so I wrote custom functions to extract these parts from the name string. Is this really necessary? Is there a built-in solution in the library for doing this, or if not, should there be?
Library Version: 32
The text was updated successfully, but these errors were encountered: