So I'm trying out the official mongodb go driver (was using mgo before), and I'm stuck. I'm trying to marshal/unmarshal a custom type, which is obviously not working by default. The documentation is kind of lacking. Basically what I would like to do…
How do I use a given slice to generate a bson.A? I need this to make dynamic queries.
I am upgrading from mongo-go-driver alpha to beta 0.2.0, and this has become a major change in my project since the API is different…
Hi there :) I'm working on a golang app linked to mongo DB (I use the official driver: mongo-go) and here's my problem,I want to execute this function
db.rmTickets.find().forEach(function(doc) {
doc.created=new Date(doc.created)
…
I am new to mongodb-go-driver and i am stuck.
I have a date inside a struct like:
type Email struct {
Date string `json:"date"`
}
the Dates on my mongoDB and mapped in my struct have the values like "02/10/2018 11:55:20".
I…
I need to build a query using comparison operators, equivalent of db.inventory.find( { qty: { $gt: 20 } using the official driver. Any idea how to do that?
I'm currently working with the mongodb driver on golang and trying to add fields to a document's array from an input array of the same type:
type Organization struct {
ID string `bson:"_id,omitempty" json:"id,omitempty" `
Name string…
I'm developing a Go application that integrates with MongoDB to create, read, and delete images. I've set the connection pool to 4 for testing purposes, but I've noticed that the number of connections can go up to 10 even if I haven't hit any…
I am coding a golang web service that has a mongo database, I am using the go.mongodb.org/mongo-driver v1.11.6 and a simple query is taking more than 2 seconds to complete. The database has only a few records, is it just for testing, no more than 10…
I'm trying to connect to my mongo Atlas database using golang mongodb official driver. The problem is that the connection seems successful but the client won't retrieve anything. I tried to log ListDatabaseNames() and ListCollectionNames() but it…
Need some help to figure out why nested bson.M doesn’t work occasionally in FindOne().
For the following Golang structs stored in a MongoDb collection for type A:
type A struct {
Id primitive.ObjectID
Random1 string
Parents []B
Random2…
I am currently creating a golang api using GoFiber V2.
I have the following document structure for a music track in a Mongo database:
{
"_id" : ObjectId("63cc26cb86ae1611380e1206"),
"active" : 1,
"exclusive" : "false",
"track_title"…
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…
Here's my problem. I'm using gqlgen library to run a GraphQL server. In my database I have a MongoDB document that looks like this:
{
"_id": ObjectID(...),
"somefield": "data",
"anArrayOfObjects": [
{
"field1": "value1",
…