From 30c681261d349a1caaf97ce10adbb1f39d784014 Mon Sep 17 00:00:00 2001 From: Rachel Mackintosh Date: Thu, 6 Mar 2025 10:53:22 -0500 Subject: [PATCH] use eg file --- .../crud/write-operations/upsert.txt | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/source/fundamentals/crud/write-operations/upsert.txt b/source/fundamentals/crud/write-operations/upsert.txt index 47859b38..865a2971 100644 --- a/source/fundamentals/crud/write-operations/upsert.txt +++ b/source/fundamentals/crud/write-operations/upsert.txt @@ -96,20 +96,12 @@ The following example performs the following actions: .. io-code-block:: :copyable: true - .. input:: + .. input:: /includes/fundamentals/code-snippets/CRUD/upsert.go + :start-after: begin upsert + :end-before: end upsert :language: go - - filter := bson.D{{"species", "Ledebouria socialis"}, {"plant_id", 3}} - update := bson.D{{"$set", bson.D{{"species", "Ledebouria socialis"}, {"plant_id", 3}, {"height", 8.3}}}} - options.UpdateOne().SetUpsert(true) - - result, err := coll.UpdateOne(context.TODO(), filter, update, opts) - if err != nil { - panic(err) - } - - fmt.Printf("Number of documents updated: %v\n", result.ModifiedCount) - fmt.Printf("Number of documents upserted: %v\n", result.UpsertedCount) + :emphasize-lines: 5 + :dedent: .. output:: :language: none