I am very new to both Go and Mongodb and was writing my first rest-api with Go and Mongo. I am using mongo-go-driver and have the following Modal struct in Go
type Modal struct {
Group []string `bson:"group" json:"group"`
Hostname string `bson:"hostname" json:"hostname"`
Overrides map[string]string `bson:"overrides" json:"overrides"`
Excludes []string `bson:"excludes" json:"excludes"`
}
I do not want to use the default ObjectId field provided by mongo-db as my primary key and instead would like to make the Hostname field as the primary key.
If I make the type of Hostname field as primitive.ObjectID, then the hostname would be unique but its value will be randomly generated string by mongodb and not the actual hostname string value.
So is there a way I can do this.