package dbs import ( "go.mongodb.org/mongo-driver/bson" ) type Input = map[string]interface{} func InputToBson(i Input, isUpdate bool) bson.D { input := bson.D{} for k, v := range i { if k == "id" { input = append(input, bson.E{Key: "_id", Value: v}) } else { input = append(input, bson.E{Key: k, Value: v}) } } if isUpdate { return bson.D{{Key: "$set", Value: input}} } return input }