Skip to main content
Filter by
Sorted by
Tagged with
1 vote
1 answer
77 views

I’m using MongoDB GoLang Driver v2 and I want to store a custom money type in MongoDB. If the value is nil, I want the BSON document to store price: null. Example document I want: { "name":...
Prakash P's user avatar
  • 4,128
1 vote
0 answers
109 views

I am trying to establish connection with mongoDB using the below code func getSession() \*mgo.Session { // Connect to MongoDB on the default port s, err := mgo.Dial("mongodb://localhost:...
rkmangalp's user avatar
2 votes
1 answer
205 views

I am migrating a go backend from using mgo to mongo-go. The service has lots of code and I have completed most of it except for a part that deals with session.Copy() method from the old mgo. The ...
dezdichado's user avatar
2 votes
0 answers
182 views

Currently, most of my production is based on microservices, and the majority of the services have already been upgraded to the official MongoDB driver. However, with the end-of-life for version 4.X ...
Rawit_S's user avatar
  • 85
1 vote
0 answers
62 views

After linking to mongodb, the Sessionid needs to be converted back to the original format as a string func main() { uri := "mongodb://root:[email protected]:32082,172.22.50.25:32083,172.22.50....
Jun Tao's user avatar
  • 11
3 votes
0 answers
39 views

basically i have this query that searches from an array of names...now i want to make it case insensitive in GO err = c.Find(bson.M{ "name": bson.M{ "$in": ...
Juanchi's user avatar
  • 41
1 vote
0 answers
211 views

I'm connecting a Go application to MongoDB using the following code: session, sessionErr := mgo.Dial("127.0.0.1:27017") The connection is established but doesn't persist as indicated in ...
Foobar's user avatar
  • 933
2 votes
1 answer
2k views

I just followed this tutorial on youtube(https://youtu.be/GwQ1hvuSNJA). But I got an error "no reachable servers" after go run main.go How can I figure it out? Should I change localhost to ...
Shift_that's user avatar
0 votes
1 answer
685 views

I am trying to $match my data after $group but it does not work. I have db with jobs. Every job has {id, batchId(a few jobs can belong to one batch), createdAt, finishedAt}. I cant understand why I am ...
Howkee's user avatar
  • 37
3 votes
1 answer
1k views

I am running the below code. When a user saved in db then blank address is saved I have assigned the null struct to address before save. I can not add the omitempty with all the fields for address ...
Swati's user avatar
  • 49
4 votes
0 answers
2k views

I'm at a bit of an impasse here with a query that SHOULD by all accounts, return results. If I run the following query in mongosh: db.events.aggregate([ {$unwind:"$features&...
Jay's user avatar
  • 85
-2 votes
1 answer
72 views

Likes have different collection, so do Posts. But, maybe it is more efficient and green that: just getting all posts and when users hover on posts fetching likes or when intersection api is triggered ...
Bitdom8's user avatar
  • 1,482
3 votes
2 answers
533 views

I'm using MongoDB driver and mgo-forked qmgo in Go to operate MongoDB (version 5.x). I have some geo-spatial data to store and query, and searched some articles and someone mentioned to create custom ...
Yueyue Wang's user avatar
1 vote
1 answer
1k views

I am trying to connect to a mongo database hosted in azure using the .crt file. I am successfully able to connect from my linux machine terminal using command: mongo mongodb://username:password@prod-...
KIRAN KUMAR B's user avatar
0 votes
1 answer
451 views

I know this has got to be simple, but for the life of me I can't seem to generate the correct final stage in my pipeline to get this working. Here are the documents output from a stage that I have in ...
Jay's user avatar
  • 85
3 votes
1 answer
2k views

I have a custom type for the purposes of formatting a time object type MyTime time.Time To use this with JSON I have implemented: func (t *MyTime) UnmarshalJSON(b []byte) error func (t MyTime) ...
Rob Rimmer's user avatar
1 vote
1 answer
1k views

I have an array of ObjectIds in my MongoDB documents and I'd like to use Go (specifically mgo.v2) to perform a query that populates them with data from the documents that they reference. For example: {...
Yukigeshiki's user avatar
0 votes
1 answer
367 views

I need to compare two fields on my mongo db database, and this is the query for that db.characters.find({$expr:{$eq:["$currentLv", "$maxLv"]}}) How can i query like this on mongo ...
Farras Herdicho's user avatar
2 votes
1 answer
834 views

I would like to build a mongo query dynamic but searching in google, i don't understand why the first query returns null. matches := []bson.M{bson.M{"$match": bson.M{"age": bson.M{&...
Jaczura Zoltán's user avatar
0 votes
2 answers
1k views

I'd like to get the names of all the keys in a MongoDB collection. For example, from this: "Id": ObjectId("5f5a010d431c4519dcda0e3d") "title": "App"...
ROHITH P's user avatar
0 votes
0 answers
836 views

I am trying to save a field in the database using a struct. In this, if I initialize this struct and do no pass a valid bson id as MasterTemplateId while performing an update operation, then it gives ...
Amandeep kaur's user avatar
0 votes
1 answer
374 views

I am working on a Golang project (db MongoDB). I have executed the below query but it is taking too much time to load the data. In this, I am getting data from 2 collections with multiple stages. db....
Swati's user avatar
  • 49
0 votes
0 answers
267 views

Currently am working in a Go project and using mongo with gopkg.in/mgo.v2 am having issues retrieving values from the database, I have a structure like: type person struct { Name string Age ...
Sredny M Casanova's user avatar
0 votes
1 answer
271 views

I'm trying to connect mongo shell with my mongo atlas M0 cluster and ending up getting this error Error Message Solution I tried which didnt work: I upgraded the monog version to 4.2 to be insync with ...
samridhi gupta's user avatar
1 vote
1 answer
426 views

My mongodb collections employee { _id:ObjectId(), "emp_name":"qwert", "emp_id":111, "emp_dept":"XYZ" "qualification":"PHD&...
Rajandeep Kaur's user avatar
1 vote
1 answer
1k views

I have a command which is made using "labix.org/v2/mgo" library err = getCollection.Find(bson.M{}).Sort("department").Distinct("department", &listedDepartment) this ...
Puneet Jindal's user avatar
-2 votes
1 answer
1k views

I am using Golang as backed language with mongodb database and also new to this language.I have used both libraries "gopkg.in/mgo.v2" and "go.mongodb.org/mongo-driver/mongo" to ...
Rajandeep Kaur's user avatar
1 vote
1 answer
189 views

mongodb collections employee { _id:ObjectId(), "emp_name":"qwert", "emp_id":111, "emp_dept":"XYZ" } { _id:ObjectId(), "emp_name":&...
Rajandeep Kaur's user avatar
0 votes
0 answers
48 views

I have an installation of Mongo v3.0.15 and I cannot execute the find command from my application. I need to build this with backward compatibility, so, which command was used instead of find for ...
Sredny M Casanova's user avatar
1 vote
1 answer
2k views

I have the following Mongo query I'm trying to translate to Go using github.com/globalsign/mgo: db.getCollection('cluster').find({"clusterName": {"$in": ["clusterA", &...
sheldonzy's user avatar
  • 6,031
0 votes
1 answer
464 views

I have data collection in MongoDB. My data was built in model tree and relationship between child node and parent node is property parentid. Here is my data architecture And here is my sample data {&...
ThanhLam112358's user avatar
1 vote
0 answers
554 views

I'm having trouble finding objects in a nested array. I need to find home/away within league array which has an events array. Example JSON: { "sportId":4, "last":266178326, "league":[ ...
Romano's user avatar
  • 117
1 vote
1 answer
565 views

I have data in MongoDB like below: {"_id":{"$oid":"5ed0cb4cb8d5570916d1ee7e"},"rolecode":"DHBK1_ROLE_05","productid":"XYZ_Platform","functioncodelist":["DHBK1_FUNC_1","DHBK1_FUNC_2","DHBK1_FUNC_3","...
ThanhLam112358's user avatar
0 votes
1 answer
882 views

I want to insert datastruct like below to MongoDB { "rolecode": "DHBK1_ROLE_04", "functioncodelist": [ "DHBK1_FUNC_1", "DHBK1_FUNC_2", ..... "DHBK1_FUNC_n"] ...
ThanhLam112358's user avatar
0 votes
1 answer
943 views

I'm having trouble with the distinct query in MongoDB. I can write it in Mongo shell, it works but I don't know how to implement it in Go code. Here is my Mongo shell code db.getCollection('...
ThanhLam112358's user avatar
-2 votes
1 answer
200 views

I have data in MongoDB as tree structure model. Here is my data structure: Here is my Mongo shell to create collection: db.users.insert({_id:"DHBK",username:"DHBK",password:"123456",lastname:"DHBK",...
ThanhLam112358's user avatar
-3 votes
2 answers
348 views

I am getting the following error while deleting from key from array of JSON objects using Go. Error: repository/orderRepository.go:394:11: first argument to delete must be map; have interface {} ...
user_agent's user avatar
1 vote
1 answer
972 views

Possibly related: How to use interface type as a model in mgo (Go)? I have a struct like so: type Game struct { ID bson.ObjectId Type string Location string Details ...
Eric Lindsey's user avatar
  • 1,132
1 vote
1 answer
258 views

I have already looked at Efficient paging in MongoDB using mgo and asked https://stackoverflow.com/review/low-quality-posts/25723764 I got the excelent response provided by @icza who shares his ...
pablomadoery's user avatar
0 votes
1 answer
70 views

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 ...
Srinivas Renduchinthala's user avatar
9 votes
1 answer
11k views

When I insert multiple documents with insert(docs...), Operation is failing & fails to insert documents if one duplicate key in a document exists in list of documents. How can I ignore this error, ...
zxxhonest's user avatar
0 votes
2 answers
1k views

am currently working in Go and have a mongo database (connected via gopkg.in/mgo.v2) so, right now I have a data structure similar to: { "_id" : "some_id_bson", "field1" : "value1", "...
Sredny M Casanova's user avatar
1 vote
3 answers
3k views

I am quite new to golang and wanted to filter name and version for packages out of a response from my mongodb. I am using mgo to get the respone from the mongodb. This is my Code to get the response ...
michisee's user avatar
0 votes
1 answer
73 views

I have some entities in my database called "events". Each of these events contain an array of string, called "tags". I want to make a query to get all the events matching an array of tags that I will ...
Alexandre Sachs's user avatar
0 votes
1 answer
763 views

I started learning performance improvements on mongoDb. And i have a question based aggregation functions. I have created a basic test collection with 3 fields product, colour and year: { "...
eemr's user avatar
  • 23
1 vote
1 answer
203 views

I'm trying to create an aggregate pipeline using the Mgo driver. I keep running into the unknown top level operator $not issue for the following setup. I'm a beginner at using go and mongo. I'm ...
Pyro's user avatar
  • 17
1 vote
1 answer
119 views

I have a collection of user documents, each with an embedded array of clients. Each object in the array has a clientID. I wanted to retrieve the user document with a client, in the clients array, ...
pro's user avatar
  • 792
0 votes
1 answer
495 views

Upon logging in to Linux box, no authentication is required to connect with MongoDB. How to connect from Go code to such MongoDB instance? I need to SSH into Linux box using username and password, ...
Test's user avatar
  • 101
3 votes
1 answer
2k views

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 ...
Malikiah's user avatar
  • 149
1 vote
1 answer
819 views

I'm trying to do a query in mongo that basically will be...Get all documents that match this instance Id AND where the status does not equal Deleted or Rejected. I figured out how to do this in ...
Lin0523's user avatar
  • 171

1
2 3 4 5
13