firestore: clarify how to check if a document doesn't exist.
Fixes #861.
Change-Id: I22ab202f235d7ff12758ca388a89fae6c1e8ee18
Reviewed-on: https://code-review.googlesource.com/22150
Reviewed-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Michael Darakananda <pongad@google.com>
diff --git a/firestore/docref.go b/firestore/docref.go
index 5a30656..6cf9332 100644
--- a/firestore/docref.go
+++ b/firestore/docref.go
@@ -54,7 +54,9 @@
return newCollRefWithParent(d.Parent.c, d, id)
}
-// Get retrieves the document. It returns an error if the document does not exist.
+// Get retrieves the document. It returns a NotFound error if the document does not exist.
+// You can test for NotFound with
+// grpc.Code(err) == codes.NotFound
func (d *DocumentRef) Get(ctx context.Context) (*DocumentSnapshot, error) {
if err := checkTransaction(ctx); err != nil {
return nil, err
@@ -64,7 +66,6 @@
}
doc, err := d.Parent.c.c.GetDocument(withResourceHeader(ctx, d.Parent.c.path()),
&pb.GetDocumentRequest{Name: d.Path})
- // TODO(jba): verify that GetDocument returns NOT_FOUND.
if err != nil {
return nil, err
}