| 1 |
package apimethods |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"fmt" |
| 6 |
"fsutils" |
| 7 |
firestore "go-genproto/googleapis/firestore/v1beta1" |
| 8 |
"userutil" |
| 9 |
) |
| 10 |
|
| 11 |
//GetDocument ... Retrieve a specific Document |
| 12 |
func GetDocument() { |
| 13 |
fmt.Println("\n:: Getting A Document ::\n") |
| 14 |
|
| 15 |
client, conn := fsutils.MakeFSClient() |
| 16 |
|
| 17 |
defer conn.Close() |
| 18 |
|
| 19 |
fmt.Print("Enter Document Name: ") |
| 20 |
docName := "projects/firestoretestclient/databases/(default)/documents/GrpcTestData/" + userutil.ReadFromConsole() |
| 21 |
|
| 22 |
getDocRequest := firestore.GetDocumentRequest{ |
| 23 |
Name: docName, |
| 24 |
} |
| 25 |
|
| 26 |
resp, err := client.GetDocument(context.Background(), &getDocRequest) |
| 27 |
|
| 28 |
if err != nil { |
| 29 |
fmt.Println(err) |
| 30 |
} |
| 31 |
|
| 32 |
userutil.DrawDocument(*resp) |
| 33 |
|
| 34 |
return |
| 35 |
} |