Skip to content

Commit e90ceaf

Browse files
updated all usage examples code (#39)
1 parent 2942951 commit e90ceaf

File tree

11 files changed

+20
-11
lines changed

11 files changed

+20
-11
lines changed

source/includes/usage-examples/code-snippets/bulk.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func main() {
3333
mongo.NewReplaceOneModel().SetFilter(bson.D{{"title", "Record of a Shriveled Datum"}}).
3434
SetReplacement(bson.D{{"title", "Dodging Greys"}, {"text", "When there're no matches, no longer need to panic. You can use upsert"}}),
3535
mongo.NewUpdateOneModel().SetFilter(bson.D{{"title", "Dodging Greys"}}).
36-
SetUpdate(bson.D{{"$set", bson.D{{"title", "Dodge The Greys"},}},}),
36+
SetUpdate(bson.D{{"$set", bson.D{{"title", "Dodge The Greys"}}}}),
3737
}
3838
opts := options.BulkWrite().SetOrdered(true)
3939

@@ -44,7 +44,7 @@ func main() {
4444
panic(err)
4545
}
4646

47-
// When you run this file for the first time, it should print:
47+
// When you run this file for the first time, it should print:
4848
// Number of documents replaced or modified: 2
4949
fmt.Printf("Number of documents replaced or modified: %d", results.ModifiedCount)
5050
}

source/includes/usage-examples/code-snippets/command.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func main() {
3939
panic(commandErr)
4040
}
4141

42-
// When you run this file, it should print: [{db sample_restaurants} {collections 2} {views 0} {objects 25554} {avgObjSize 548.4101901854896} {dataSize 14014074} {storageSize 8257536} {totalFreeStorageSize 0} {numExtents 0} {indexes 2} {indexSize 286720} {fileSize 0} {nsSizeMB 0} {ok 1}]
42+
// When you run this file, it should print:
43+
// [{db sample_restaurants} {collections 2} {views 0} {objects 25554} {avgObjSize 548.4101901854896} {dataSize 14014074} {storageSize 8257536} {totalFreeStorageSize 0} {numExtents 0} {indexes 2} {indexSize 286720} {fileSize 0} {nsSizeMB 0} {ok 1}]
4344
fmt.Println(result)
4445
}

source/includes/usage-examples/code-snippets/count.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ func main() {
4545
// When you run this file, it should print:
4646
// Estimated number of documents in the movies collection: 23541
4747
// Number of movies from China: 303
48-
4948
fmt.Printf("Estimated number of documents in the movies collection: %d\n", estCount)
5049
fmt.Printf("Number of movies from China: %d\n", count)
5150
}

source/includes/usage-examples/code-snippets/deleteMany.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func main() {
3838
panic(err)
3939
}
4040

41-
// When you run this file for the first time, it should print "Documents deleted: 4"
41+
// When you run this file for the first time, it should print:
42+
// Documents deleted: 4
4243
fmt.Printf("Documents deleted: %d\n", results.DeletedCount)
4344
}

source/includes/usage-examples/code-snippets/deleteOne.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"go.mongodb.org/mongo-driver/mongo"
1111
"go.mongodb.org/mongo-driver/mongo/options"
1212
)
13-
13+
1414
func main() {
1515
var uri string
1616
if uri = os.Getenv("MONGODB_URI"); uri == "" {
@@ -38,6 +38,7 @@ func main() {
3838
panic(err)
3939
}
4040

41-
// When you run this file for the first time, it should print "Documents deleted: 1"
41+
// When you run this file for the first time, it should print:
42+
// Documents deleted: 1
4243
fmt.Printf("Documents deleted: %d\n", result.DeletedCount)
4344
}

source/includes/usage-examples/code-snippets/distinct.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func main() {
3838
panic(err)
3939
}
4040

41-
// When you run this file, it should print:
41+
// When you run this file, it should print:
4242
// A Tale of Love and Darkness
4343
// New York, I Love You
4444
for _, result := range results {

source/includes/usage-examples/code-snippets/insertMany.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ func main() {
4141
panic(err)
4242
}
4343

44-
// When you run this file it should print "2 documents inserted with IDs: ...
44+
// When you run this file, it should print:
45+
// 2 documents inserted with IDs: ObjectID("..."), ObjectID("...")
4546
fmt.Printf("%d documents inserted with IDs:\n", len(result.InsertedIDs))
4647
for _, id := range result.InsertedIDs {
4748
fmt.Printf("\t%s\n", id)

source/includes/usage-examples/code-snippets/insertOne.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func main() {
3838
panic(err)
3939
}
4040

41-
// When you run this file it should print "Document inserted with ID: ObjectID("...")
41+
// When you run this file, it should print:
42+
// Document inserted with ID: ObjectID("...")
4243
fmt.Printf("Document inserted with ID: %s\n", result.InsertedID)
4344
}

source/includes/usage-examples/code-snippets/replace.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ func main() {
3939
panic(err)
4040
}
4141

42-
// When you run this file for the first time, it should print: "Number of documents replaced: 1"
42+
// When you run this file for the first time, it should print:
43+
// Number of documents replaced: 1
4344
if result.MatchedCount != 0 {
4445
fmt.Println("Number of documents replaced: %d\n", result.ModifiedCount)
4546
}

source/includes/usage-examples/code-snippets/updateMany.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,7 @@ func main() {
3939
panic(err)
4040
}
4141

42+
// When you run this file for the first time, it should print:
43+
// Number of documents replaced: 609
4244
fmt.Printf("Documents updated: %v\n", result.ModifiedCount)
4345
}

0 commit comments

Comments
 (0)