From 7d785f5f7e640a46fca8357f4a3d3cb4a2b0d608 Mon Sep 17 00:00:00 2001 From: Cory Schwartz Date: Tue, 21 Nov 2023 18:28:12 -0800 Subject: [PATCH] add support for non-default databases --- docstore/gcpfirestore/fs.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docstore/gcpfirestore/fs.go b/docstore/gcpfirestore/fs.go index c7527d0c92..759a8a1c1f 100644 --- a/docstore/gcpfirestore/fs.go +++ b/docstore/gcpfirestore/fs.go @@ -149,6 +149,10 @@ func CollectionResourceID(projectID, collPath string) string { return fmt.Sprintf("projects/%s/databases/(default)/documents/%s", projectID, collPath) } +func CollectionResourceIDWithDatabase(projectID, databaseID, collPath string) string { + return fmt.Sprintf("projects/%s/databases/%s/documents/%s", projectID, databaseID, collPath) +} + // OpenCollection creates a *docstore.Collection representing a Firestore collection. // // collResourceID must be of the form "project//databases/(default)/documents/". @@ -193,7 +197,7 @@ func OpenCollectionWithNameFunc(client *vkit.Client, collResourceID string, name return docstore.NewCollection(c), nil } -var resourceIDRE = regexp.MustCompile(`^(projects/[^/]+/databases/\(default\))/documents/.+`) +var resourceIDRE = regexp.MustCompile(`^(projects/[^/]+/databases/[^/]+)/documents/.+`) func newCollection(client *vkit.Client, collResourceID, nameField string, nameFunc func(docstore.Document) string, opts *Options) (*collection, error) { if nameField == "" && nameFunc == nil {