Issue I’m trying to use the mtest package (https://pkg.go.dev/go.mongodb.org/mongo-driver/mongo/integration/mtest) to perform some testing with mock results on my MongoDB calls, but I can’t seem to figure out how to properly mock the *mongo.UpdateResult value that gets returned when you make
Continue readingTag: mongodb
Rotate MongoDb collection automatically in a periodic manner
Issue Let’s say I have a mongo collection ("resultData"). I want that every month collection rotation happens (similar to log rotation or archiving) and automatically rename the old collection to "{{old_collection_name}}_{{month_year}}." This will help me to keep all data without
Continue readingMongoDB GO driver overwriting existing data
Issue I am using GO-FIBER and using MONGODB MongoDB Go Driver. I want to update only the fields given by the body. But it is overwriting the data. func UpdateOneUser(c *fiber.Ctx) error { params := c.Params("id") body := new(models.User) id,
Continue readingfilter query mongoldb Golang
Issue I am trying to get a list of data that match specific queries but I am getting this error "(AtlasError) merchant is not allowed or the syntax is incorrect, see the Atlas documentation for more information" func … var
Continue readingRedefine the bson tag in golang, how to be compatible with the fields in the database with lowercase field names?
Issue There are many structures(There are roughly hundreds of structures, all generated automatically by a tool.) like this: type ChatInfo struct { Name string `json:"name"` IconFrame uint64 `json:"iconFrame"` } The bson tag was forgotten, causing the field name in the
Continue readingRedefine the bson tag in golang, how to be compatible with the fields in the database with lowercase field names?
Issue There are many structures(There are roughly hundreds of structures, all generated automatically by a tool.) like this: type ChatInfo struct { Name string `json:"name"` IconFrame uint64 `json:"iconFrame"` } The bson tag was forgotten, causing the field name in the
Continue readingGetting all data from mongodb compound collection with filter in golang
Issue I try to make get all data with Name field where I specify in API Request Body. I made a filter for .Find() function. But I can’t get any result (response body says null, No errors at all). You
Continue readingHow would I update multiple records based on different key in Mongo in one query?
Issue If I have something similar to the following… collection.InsertMany(context.TODO(), []interface{}{ bson.M{ "_id" : 1, "member" : "abc123", "status" : "P" }, bson.M{ "_id" : 2, "member" : "xyz123", "status" : "A" }, bson.M{ "_id" : 3, "member" : "lmn123",
Continue readingmgo is setting objectid to objectidhex, which doesnt seem to get read by Mongodb
Issue I am trying to make a query using the ObjectId, and normally in mongodb you would do something like this db.collection.findOne({“_id”:objectid(“5d9d90e5ed645489aae6df64”)}) Which this works when I do a normal query but in go lang it gives it the value
Continue readingcould not parse line #126: mongo.database = mongo_db_test
Issue I’m following this tutorial Golang + Revel web framework + Mongodb RESTFul generator for (revel_mgo) step by step, but when I finally end it and try to run it, it throw this error CRIT 16:11:18 revel_container.go:139: Unable to load
Continue reading