MCPcopy Create free account
hub / github.com/google/go-cloud / Example_openCollectionFromURL

Function Example_openCollectionFromURL

docstore/mongodocstore/example_test.go:70–82  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

68}
69
70func Example_openCollectionFromURL() {
71 // PRAGMA: This example is used on gocloud.dev; PRAGMA comments adjust how it is shown and can be ignored.
72 // PRAGMA: On gocloud.dev, add a blank import: _ "gocloud.dev/docstore/mongodocstore"
73 // PRAGMA: On gocloud.dev, hide lines until the next blank line.
74 ctx := context.Background()
75
76 // docstore.OpenCollection creates a *docstore.Collection from a URL.
77 coll, err := docstore.OpenCollection(ctx, "mongo://my-db/my-collection?id_field=userID")
78 if err != nil {
79 log.Fatal(err)
80 }
81 defer coll.Close()
82}

Callers

nothing calls this directly

Calls 2

OpenCollectionFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected