In this article, php editor Xiaoxin will introduce to you how to use Go language to connect to a non-default Firestore database. Firestore is a flexible and scalable NoSQL document database, but by default it only connects to the default database for Google Cloud projects. However, sometimes we may need to connect to a different database, and this article will teach you how to achieve this. Whether you are a newbie or an experienced developer, this article will provide you with easy-to-follow steps and sample code to help you successfully connect to a non-default Firestore database. let's start!
I saw a post about using node to connect to a non-default Firestore database. I was wondering if anyone knows the same functionality in the firestore Go package?
I tried direct translation but no success. Maybe the package hasn't been updated with this feature yet?
Call NewClientWithDatabase to connect to a specific database.
ctx := context.Background() client, err := firestore.NewClientWithDatabase(ctx, projectID, databaseID) if err != nil { // TODO: Handle error. } defer client.Close() // Close client when done.
The above is the detailed content of How to connect to a non-default firestore database using Go?. For more information, please follow other related articles on the PHP Chinese website!