Hi,
I was looking into the Go Driver 2.0 migration. It seems to me that “options.ArrayFilters” is gone and the documentation outdated. Picking up on the example and official documentation:
opts := options.FindOneAndUpdate().
SetArrayFilters(options.ArrayFilters{Filters: identifier}).
SetReturnDocument(options.After)
I am unable to find ‘options.ArrayFilters’ in the 2.0 release. The ArrayFilters struct is in the 1.17 release:
// Copyright (C) MongoDB, Inc. 2017-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
package options
import (
"fmt"
"reflect"
"strconv"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
)
// Collation allows users to specify language-specific rules for string comparison, such as
// rules for lettercase and accent marks.
This file has been truncated. show original
but not in the 2.0 release anymore:
// Copyright (C) MongoDB, Inc. 2017-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
package options
import (
"go.mongodb.org/mongo-driver/v2/bson"
)
var defaultRegistry = bson.NewRegistry()
// Collation allows users to specify language-specific rules for string comparison, such as
// rules for lettercase and accent marks.
type Collation struct {
Locale string `bson:",omitempty"` // The locale
CaseLevel bool `bson:",omitempty"` // The case level
CaseFirst string `bson:",omitempty"` // The case ordering
This file has been truncated. show original
Best regards,
Timo
Hi @Timo_Guhring , thanks for catching this! I will pass this on to our Docs team so they can update the documentation
In your example, you can pass the filter in directly now:
opts := options.FindOneAndUpdate().
SetArrayFilters(identifier).
SetReturnDocument(options.After)
Great, thank you! Passing the identifier directly works.
1 Like