How can i set a bit, using the $set and $bit operators in mongodb in Golang?

Viewed 20

Is that even possible? I have found this: https://www.mongodb.com/docs/manual/reference/operator/query/bitsAllSet/ But i don't quite understand. I couldn't derive from that documentation whether it's possible to set a bit in mongodb?

I tried this:

            update := bson.M{
                "$set": bson.M{
                    "$bit": bson.M{
                        "bitfield": bson.M{"or": 1},
                    },
                },
            }

But in the mongodb database, it displays bitfield field, as Int32. Why is that? It should store it as a byte array.

0 Answers
Related