All Questions
21
questions
1
vote
1
answer
100
views
How can I troubleshoot empty data values when saving to MongoDB in Golang?
I'm a newcomer to Golang, and I'm facing an issue with saving data to a database. After receiving a JSON object from an API, I'm attempting to store it in MongoDB, but the data is being saved with ...
1
vote
0
answers
56
views
How to Update MongoDB GridFS Chunk Data in Go?
Hey Stack Overflow community! I'm facing a challenge with updating the data field of files stored in my MongoDB using GridFS. I'm not quite sure how to approach it, and I could use some guidance.
Here'...
2
votes
1
answer
240
views
CodeQL: Gin / MongoDB API - Database query built from user-controlled sources error
I have a simple Golang Gin API that uses MongoDB as the backend database. My team is using GitHub CodeQL, so we want to be sure we are following the best standards. However, we continue to get this ...
2
votes
1
answer
287
views
Additional "id" field generated when posting into MongoDB
I'm learning Go and Gin framework.
I built a simple microservice connected to a MongoDB collection, everything works but when I add a document using a POST it adds the "id" field instead of ...
0
votes
0
answers
133
views
CPU usage increasing day by day because of Cron
I am running a cron whose code is written in Golang,and i am using mongoDb(version -4.4) as database, the cron runs after every 5 minutes of interval, i have been noticing that when i start the cron ...
1
vote
1
answer
567
views
Adding information to Golang Gin HTTP error responses
I am trying to return a custom error response when an HTTP 500 Internal Error is encountered. If I use c.JSON(http.StatusInternalServerError, CustomError{}) when a database write error occurs, Gin ...
0
votes
0
answers
294
views
MongoDB overwrite validation error messages
I am using mongodb and mongo-driver to manage models and its data. I should translate the default validation messages to my native language.
That being said, I have being reading the mongo-driver ...
0
votes
1
answer
390
views
Reading documents from MongoDB with GoLang
I am able to read and write documents to database but I am experiencing some very strange behavior.
If search for the name "jack" I get every document and Mike I get just one document but ...
1
vote
2
answers
525
views
How to remove nested field in golang mongodb group aggregation?
I beginner in golang and mongodb, and I have problem with remove nested field using aggregate group mongodb. I just read the mongodb doc and I think remove field can handle with mongodb $project but I ...
0
votes
2
answers
796
views
Cannot use primitive.ObjectId as a type with the form binding In Gin
package main
import (
"github.com/gin-gonic/gin"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"net/http"
)
...
1
vote
0
answers
378
views
Initialize MongoDB Array field in Go
I have this data schema:
"person": {
"name": "John",
"pets": [
{
"name": "Birdie"
}
]
}
This is the struct to insert ...
0
votes
1
answer
264
views
Skip binding ID but return it as a response
I have a Person struct as follows:
type Person struct {
ID primitive.ObjectID `bson:"_id,omitempty" json:"id"`
HomeAddress Address `bson:"home_address" json:"...
0
votes
1
answer
64
views
How to fetchall records in mongodb mgo.v2?
I Want to fetch all records in database By using NAME but, if I am using ALL it is showing 500 internal error but, if I Kept One(JSON) I am getting only one record. What is the solution to fetch all ...
0
votes
0
answers
880
views
Postman can't handle JSON response with long string
I was building an API with GO that retrieves some data from a MongoDB database and responds with a JSON
So everything works fine until I put in the "Content" line, and the problem seems to be limited ...
0
votes
0
answers
46
views
Fetch info of multiple struct dynamically in loop
I need to fetch collection list and each collection's keys from Mongodb and compare those key in loop with struct which has same name as collection name
Struct in dettails.go
type Chats struct {
...