()
| 113 | } |
| 114 | |
| 115 | func ExampleCollection_As() { |
| 116 | // This example is specific to the gcpfirestore implementation; it demonstrates |
| 117 | // access to the underlying *cloud.google.com/go/firestore/apiv1.Client. |
| 118 | |
| 119 | // You will need to blank-import the package for this to work: |
| 120 | // import _ "gocloud.dev/docstore/gcpfirestore" |
| 121 | |
| 122 | // The types exposed for As by gcpfirestore are documented in |
| 123 | // https://godoc.org/gocloud.dev/docstore/gcpfirestore#hdr-As |
| 124 | |
| 125 | // This URL will open the collection using default credentials. |
| 126 | ctx := context.Background() |
| 127 | coll, err := docstore.OpenCollection(ctx, |
| 128 | "firestore://projects/myproject/databases/(default)/documents/mycollection?name_field=myID") |
| 129 | if err != nil { |
| 130 | log.Fatal(err) |
| 131 | } |
| 132 | defer coll.Close() |
| 133 | |
| 134 | // Try to access and use the underlying mongo.Collection. |
| 135 | var fsClient *firestore.Client |
| 136 | if coll.As(&fsClient) { |
| 137 | _ = fsClient // TODO: Use the client. |
| 138 | } else { |
| 139 | log.Println("Unable to access firestore.Client through Collection.As") |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | func ExampleCollection_ErrorAs() { |
| 144 | // This example is specific to the awsdynamodb implementation. |
nothing calls this directly
no test coverage detected