Regex query with the Go driver

I have

			games, e = h.service.GameRepo().Find(bson.M{
				"slug": bson.M{"$regex": primitive.Regex{
					Pattern: "^[0-9]",
					Options: "i",
				}},
			}, &options.FindOptions{
				Sort: bson.D{{"name", 1}},
			})

The result is it returns ALL documents.

I also had

			games, e = h.service.GameRepo().Find(bson.D{{
				Key: "slug", Value: primitive.Regex{
					Pattern: "^[0-9]",
					Options: "i",
				},
			}}, &options.FindOptions{
				Sort: bson.D{{"name", 1}},
			})

same result

but also

			games, e = h.service.GameRepo().Find(bson.D{{
				Key: "slug", Value: bson.E{
					Key: "$regex",
					Value: primitive.Regex{
						Pattern: "^[0-9]",
						Options: "i",
					},
				},
			}}, &options.FindOptions{
				Sort: bson.D{{"name", 1}},
			})

What do I have to do so the filter actually works?

The mgo driver was straightforward, this driver is just awful!
Why are there bson.M bson.D bson.A bson.E
Why this overcomplication? Development time has increased 10fold with this driver compared to the mgo driver.
I don’t like SQL but lately I’ve been considering to completely get rid of mongodb in favor of Postgresql, because the drivers available are actually straightforward and don’t let the user jump through hoops of ridiculous data types.
Also you never answered my Rust question.

Hi @dalu,

Can you let us know what the query looked like with mgo? We can try to help you translate it based on that information.

– Divjot