Skip to content

GODRIVER-2247 Add missing comments to exported functions/types #823

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bson/marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,13 @@ func MarshalExtJSONAppendWithContext(ec bsoncodec.EncodeContext, dst []byte, val
return *sw, nil
}

// IndentExtJSON will prefix and indent the provided extended JSON src and append it to dst.
func IndentExtJSON(dst *bytes.Buffer, src []byte, prefix, indent string) error {
return json.Indent(dst, src, prefix, indent)
}

// MarshalExtJSONIndent returns the extended JSON encoding of val with each line with prefixed
// and indented.
func MarshalExtJSONIndent(val interface{}, canonical, escapeHTML bool, prefix, indent string) ([]byte, error) {
marshaled, err := MarshalExtJSON(val, canonical, escapeHTML)
if err != nil {
Expand Down
4 changes: 3 additions & 1 deletion x/mongo/driver/operation/aggregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"go.mongodb.org/mongo-driver/x/mongo/driver/session"
)

// Performs an aggregate operation
// Aggregate represents an aggregate operation.
type Aggregate struct {
allowDiskUse *bool
batchSize *int32
Expand Down Expand Up @@ -67,6 +67,8 @@ func (a *Aggregate) Result(opts driver.CursorOptions) (*driver.BatchCursor, erro
return driver.NewBatchCursor(a.result, clientSession, clock, opts)
}

// ResultCursorResponse returns the underlying CursorResponse result of executing this
// operation.
func (a *Aggregate) ResultCursorResponse() driver.CursorResponse {
return a.result
}
Expand Down
3 changes: 2 additions & 1 deletion x/mongo/driver/operation/count.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"go.mongodb.org/mongo-driver/x/mongo/driver/session"
)

// Performs a count operation
// Count represents a count operation.
type Count struct {
maxTimeMS *int64
query bsoncore.Document
Expand All @@ -39,6 +39,7 @@ type Count struct {
serverAPI *driver.ServerAPIOptions
}

// CountResult represents a count result returned by the server.
type CountResult struct {
// The number of documents found
N int64
Expand Down
25 changes: 13 additions & 12 deletions x/mongo/driver/operation/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"go.mongodb.org/mongo-driver/x/mongo/driver/session"
)

// Create a create operation
// Create represents a create operation.
type Create struct {
capped *bool
collation bsoncore.Document
Expand Down Expand Up @@ -127,7 +127,7 @@ func (c *Create) command(dst []byte, desc description.SelectedServer) ([]byte, e
return dst, nil
}

// Specifies if the collection is capped.
// Capped specifies if the collection is capped.
func (c *Create) Capped(capped bool) *Create {
if c == nil {
c = new(Create)
Expand All @@ -147,7 +147,7 @@ func (c *Create) Collation(collation bsoncore.Document) *Create {
return c
}

// Specifies the name of the collection to create.
// CollectionName specifies the name of the collection to create.
func (c *Create) CollectionName(collectionName string) *Create {
if c == nil {
c = new(Create)
Expand All @@ -157,7 +157,7 @@ func (c *Create) CollectionName(collectionName string) *Create {
return c
}

// Specifies a default configuration for indexes on the collection.
// IndexOptionDefaults specifies a default configuration for indexes on the collection.
func (c *Create) IndexOptionDefaults(indexOptionDefaults bsoncore.Document) *Create {
if c == nil {
c = new(Create)
Expand All @@ -167,7 +167,7 @@ func (c *Create) IndexOptionDefaults(indexOptionDefaults bsoncore.Document) *Cre
return c
}

// Specifies the maximum number of documents allowed in a capped collection.
// Max specifies the maximum number of documents allowed in a capped collection.
func (c *Create) Max(max int64) *Create {
if c == nil {
c = new(Create)
Expand All @@ -177,7 +177,7 @@ func (c *Create) Max(max int64) *Create {
return c
}

// Specifies the agggregtion pipeline to be run against the source to create the view.
// Pipeline specifies the agggregtion pipeline to be run against the source to create the view.
func (c *Create) Pipeline(pipeline bsoncore.Document) *Create {
if c == nil {
c = new(Create)
Expand All @@ -187,7 +187,7 @@ func (c *Create) Pipeline(pipeline bsoncore.Document) *Create {
return c
}

// Specifies the maximum size in bytes for a capped collection.
// Size specifies the maximum size in bytes for a capped collection.
func (c *Create) Size(size int64) *Create {
if c == nil {
c = new(Create)
Expand All @@ -197,7 +197,7 @@ func (c *Create) Size(size int64) *Create {
return c
}

// Specifies the storage engine to use for the index.
// StorageEngine specifies the storage engine to use for the index.
func (c *Create) StorageEngine(storageEngine bsoncore.Document) *Create {
if c == nil {
c = new(Create)
Expand All @@ -207,7 +207,7 @@ func (c *Create) StorageEngine(storageEngine bsoncore.Document) *Create {
return c
}

// Specifies what should happen if a document being inserted does not pass validation.
// ValidationAction specifies what should happen if a document being inserted does not pass validation.
func (c *Create) ValidationAction(validationAction string) *Create {
if c == nil {
c = new(Create)
Expand All @@ -217,7 +217,8 @@ func (c *Create) ValidationAction(validationAction string) *Create {
return c
}

// Specifies how strictly the server applies validation rules to existing documents in the collection during update operations.
// ValidationLevel specifies how strictly the server applies validation rules to existing documents in the collection
// during update operations.
func (c *Create) ValidationLevel(validationLevel string) *Create {
if c == nil {
c = new(Create)
Expand All @@ -227,7 +228,7 @@ func (c *Create) ValidationLevel(validationLevel string) *Create {
return c
}

// Specifies validation rules for the collection.
// Validator specifies validation rules for the collection.
func (c *Create) Validator(validator bsoncore.Document) *Create {
if c == nil {
c = new(Create)
Expand All @@ -237,7 +238,7 @@ func (c *Create) Validator(validator bsoncore.Document) *Create {
return c
}

// Specifies the name of the source collection or view on which the view will be created.
// ViewOn specifies the name of the source collection or view on which the view will be created.
func (c *Create) ViewOn(viewOn string) *Create {
if c == nil {
c = new(Create)
Expand Down
9 changes: 5 additions & 4 deletions x/mongo/driver/operation/createIndexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type CreateIndexes struct {
serverAPI *driver.ServerAPIOptions
}

// CreateIndexesResult represents a createIndexes result returned by the server.
type CreateIndexesResult struct {
// If the collection was created automatically.
CreatedCollectionAutomatically bool
Expand Down Expand Up @@ -133,9 +134,9 @@ func (ci *CreateIndexes) command(dst []byte, desc description.SelectedServer) ([
return dst, nil
}

// The number of data-bearing members of a replica set, including the primary, that must complete the index builds
// successfully before the primary marks the indexes as ready. This should either be a string or int32 value.
//
// CommitQuorum specifies the number of data-bearing members of a replica set, including the primary, that must
// complete the index builds successfully before the primary marks the indexes as ready. This should either be a
// string or int32 value.
func (ci *CreateIndexes) CommitQuorum(commitQuorum bsoncore.Value) *CreateIndexes {
if ci == nil {
ci = new(CreateIndexes)
Expand All @@ -145,7 +146,7 @@ func (ci *CreateIndexes) CommitQuorum(commitQuorum bsoncore.Value) *CreateIndexe
return ci
}

// An array containing index specification documents for the indexes being created.
// Indexes specifies an array containing index specification documents for the indexes being created.
func (ci *CreateIndexes) Indexes(indexes bsoncore.Document) *CreateIndexes {
if ci == nil {
ci = new(CreateIndexes)
Expand Down
1 change: 1 addition & 0 deletions x/mongo/driver/operation/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Delete struct {
serverAPI *driver.ServerAPIOptions
}

// DeleteResult represents a delete result returned by the server.
type DeleteResult struct {
// Number of documents successfully deleted.
N int32
Expand Down
1 change: 1 addition & 0 deletions x/mongo/driver/operation/distinct.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type Distinct struct {
serverAPI *driver.ServerAPIOptions
}

// DistinctResult represents a distinct result returned by the server.
type DistinctResult struct {
// The distinct values for the field.
Values bsoncore.Value
Expand Down
1 change: 1 addition & 0 deletions x/mongo/driver/operation/drop_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type DropCollection struct {
serverAPI *driver.ServerAPIOptions
}

// DropCollectionResult represents a dropCollection result returned by the server.
type DropCollectionResult struct {
// The number of indexes in the dropped collection.
NIndexesWas int32
Expand Down
1 change: 1 addition & 0 deletions x/mongo/driver/operation/drop_indexes.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type DropIndexes struct {
serverAPI *driver.ServerAPIOptions
}

// DropIndexesResult represents a dropIndexes result returned by the server.
type DropIndexesResult struct {
// Number of indexes that existed before the drop was executed.
NIndexesWas int32
Expand Down
2 changes: 1 addition & 1 deletion x/mongo/driver/operation/end_sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (es *EndSessions) command(dst []byte, desc description.SelectedServer) ([]b
return dst, nil
}

// sessionIDs specify the sessions to be expired.
// SessionIDs specifies the sessions to be expired.
func (es *EndSessions) SessionIDs(sessionIDs bsoncore.Document) *EndSessions {
if es == nil {
es = new(EndSessions)
Expand Down
2 changes: 1 addition & 1 deletion x/mongo/driver/operation/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (f *Find) OplogReplay(oplogReplay bool) *Find {
return f
}

// Project limits the fields returned for all documents.
// Projection limits the fields returned for all documents.
func (f *Find) Projection(projection bsoncore.Document) *Find {
if f == nil {
f = new(Find)
Expand Down
2 changes: 2 additions & 0 deletions x/mongo/driver/operation/find_and_modify.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ type FindAndModify struct {
result FindAndModifyResult
}

// LastErrorObject represents information about updates and upserts returned by the server.
type LastErrorObject struct {
// True if an update modified an existing document
UpdatedExisting bool
// Object ID of the upserted document.
Upserted interface{}
}

// FindAndModifyResult represents a findAndModify result returned by the server.
type FindAndModifyResult struct {
// Either the old or modified document, depending on the value of the new parameter.
Value bsoncore.Document
Expand Down
1 change: 1 addition & 0 deletions x/mongo/driver/operation/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type Insert struct {
serverAPI *driver.ServerAPIOptions
}

// InsertResult represents an insert result returned by the server.
type InsertResult struct {
// Number of documents successfully inserted.
N int32
Expand Down
1 change: 1 addition & 0 deletions x/mongo/driver/operation/listDatabases.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ type ListDatabases struct {
result ListDatabasesResult
}

// ListDatabasesResult represents a listDatabases result returned by the server.
type ListDatabasesResult struct {
// An array of documents, one document for each database
Databases []databaseRecord
Expand Down