Skip to content

Commit

Permalink
Fixed mongo issue with new package
Browse files Browse the repository at this point in the history
  • Loading branch information
mrz1836 committed Jun 27, 2023
1 parent 714dd7b commit c866330
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 27 deletions.
10 changes: 4 additions & 6 deletions go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 9 additions & 18 deletions go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions index.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package datastore
import (
"context"

"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
)

// IndexExists check whether the given index exists in the datastore
Expand Down Expand Up @@ -64,13 +64,22 @@ func (c *Client) IndexMetadata(tableName, field string) error {
return tx.Error
} else if c.Engine() == MongoDB {
ctx := context.Background()
return createMongoIndex(ctx, c.options, tableName, true, mongo.IndexModel{Keys: bsonx.Doc{{

// todo: this changed in the new version of mongo (needs to be tested)
/*return createMongoIndex(ctx, c.options, tableName, true, mongo.IndexModel{Keys: bsonx.Doc{{
Key: metadataField + ".k",
Value: bsonx.Int32(1),
}, {
Key: metadataField + ".v",
Value: bsonx.Int32(1),
}}})
}}})*/

return createMongoIndex(ctx, c.options, tableName, true, mongo.IndexModel{
Keys: bson.D{
{Key: metadataField + ".k", Value: 1},
{Key: metadataField + ".v", Value: 1},
},
})
}

return nil
Expand Down

0 comments on commit c866330

Please sign in to comment.