Skip to content

Commit

Permalink
add support for non-default databases
Browse files Browse the repository at this point in the history
  • Loading branch information
coryschwartz committed Nov 22, 2023
1 parent 6d5d289 commit 7d785f5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docstore/gcpfirestore/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/<projectID>/databases/(default)/documents/<collPath>".
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 7d785f5

Please sign in to comment.