| 1 |
package apimethods |
| 2 |
|
| 3 |
import ( |
| 4 |
"context" |
| 5 |
"fmt" |
| 6 |
"fsutils" |
| 7 |
firestore "go-genproto/googleapis/firestore/v1beta1" |
| 8 |
) |
| 9 |
|
| 10 |
//ListCollectionIds ... List all collection IDs from a database |
| 11 |
func ListCollectionIds() { |
| 12 |
fmt.Println("\n:: Listing All Collection Ids ::\n") |
| 13 |
|
| 14 |
client, conn := fsutils.MakeFSClient() |
| 15 |
|
| 16 |
defer conn.Close() |
| 17 |
|
| 18 |
listCollectionIdReq := firestore.ListCollectionIdsRequest{ |
| 19 |
Parent: "projects/firestoretestclient/databases/(default)", |
| 20 |
} |
| 21 |
|
| 22 |
resp, err := client.ListCollectionIds(context.Background(), &listCollectionIdReq) |
| 23 |
|
| 24 |
if err != nil { |
| 25 |
fmt.Println(err) |
| 26 |
return |
| 27 |
} |
| 28 |
|
| 29 |
for _, cid := range resp.CollectionIds { |
| 30 |
fmt.Println(cid) |
| 31 |
} |
| 32 |
|
| 33 |
return |
| 34 |
|
| 35 |
} |