mgo Questions

4

Solved

I'm trying to install mgo which is a mongo-driver written in golang. The standard command: go get launchpad.net/mgo But it failed because of some cert issues. So I manually download the sour...
Heads asked 27/5, 2012 at 9:2

1

Solved

While testing some of my codebase I found it useful to mock out objects from "gopkg.in/mgo.v2" with interfaces. I'm running into a problem where mgo.Query does not implement my interface Query. im...
Hephzibah asked 15/9, 2017 at 16:28

1

Solved

I am using mgo library for mongo operationg in golang and here is my code : session.SetMode(mgo.Monotonic, true) coll := session.DB("aaaw_web").C("cron_emails") var result Result fmt.Printf("%v", ...
Surveyor asked 7/7, 2017 at 8:55

2

Solved

2 Parts to the question. 1 is the mongodb query itself, the next is how to do it in mgo. How do I query for 1 document of type category (the result should be of type category) where the slug: "ge...
Throughout asked 19/3, 2014 at 13:29

1

Solved

I have a GoLang code: c.Find(selectQuery).All(&results) if err == mgo.ErrNotFound { // error handling } selectQuery value is not important here. I never get error ErrNotFound. Even if the q...
Shetler asked 1/6, 2017 at 8:51

1

var ( type User struct{ Id bson.ObjectId `bson:"_id"` Name string } type Post struct{ Id bson.ObjectId `bson:"_id"` Uid string User User ref mgo.DBRef Title string } ) //try 10000 ti...
Bunnie asked 22/8, 2015 at 8:13

2

Solved

I have two MongoDB servers. From one I receive data using mongo go driver. The received data has one date field which is always null. Then in my code I may or may not change it to some other date o...
Jala asked 27/4, 2017 at 9:9

1

Solved

It is kind of stupid syntax error, tried tons of ways, just couldn't get it work, someone please help. MongoDB in Go with mgo, I just tried to simplify use the $ne operator, code like below, but k...
Viburnum asked 2/3, 2017 at 11:51

1

I have a replica set from MongoDB atlas, to which I can connect with ANY other language, and regular mongo client, with the URL provided with the format : mongodb://user:[email protected]:2701...
Atmospherics asked 15/12, 2016 at 21:35

2

Solved

I wish to use MongoDB in webapp written in Go. Can I have one mgo.Session and use it concurrently in web app. e.g. in http.Handler or should I call Session.Copy and Session.Close -> make pool of...
Neoplasty asked 27/2, 2017 at 17:25

1

Solved

In mongoose(node.js) I can define a model schema with a default Date.now like so: ... type: Date, default: Date.now ... How do I achieve the same without having to insert the time.Time every tim...
Dieter asked 28/1, 2017 at 8:2

1

I am accessing MongoDB using Go as follows: var configRes *clientConfigData err := clientDB. C(clientConfigCollection). Find(bson.M{}). One(&configRes) if err != nil { return nil, errors.W...
Preter asked 20/2, 2017 at 11:8

1

Solved

I would like to find a data by _id. I know that this data exists and that this _id exist (I've tested it with pymongo). But the code below doesn't find it: type id_cookie struct { IdCookie int }...
Boynton asked 20/12, 2016 at 13:56

1

Solved

My data layer uses Mongo aggregation a decent amount, and on average, queries are taking 500-650ms to return. I am using mgo. A sample query function is shown below which represents what most of m...
Denture asked 6/12, 2016 at 15:59

3

Solved

I'm currently using a mongodb with mgo lib for a web application, but I'm not sure if the way I'm using it, is good one .. package db import ( "gopkg.in/mgo.v2" ) const ( MongoServerAddr = "19...
Redbird asked 26/10, 2014 at 15:22

1

Solved

I've searched and found no Go solution to the problem, not with or without using mgo.v2, not on StackOverflow and not on any other site. This Q&A is in the spirit of knowledge sharing / documen...
Sonyasoo asked 16/11, 2016 at 14:38

2

Solved

I know this problem maybe duplicate to this one. But it hasn't get a satisfied answer till now. And I really want to draw some attention to get a solution as soon as possible. So I beg you not to c...
Storeroom asked 12/3, 2015 at 10:42

1

MongoDB servers are queried with multiple consistency rules. In mgo, SetMode of the Session object changes the consistency mode for the session. Three types of consistency modes are available: Ev...
Roulers asked 25/7, 2016 at 15:53

2

Solved

I tried to push some data in nested array using $push. Here is my json file { "_id" : ObjectId("57307906f051147d5317984e"), "user" : [ { "firstName" : "chetan", "lastName" : "kumar", "age" :...
Intricate asked 24/5, 2016 at 7:53

1

Solved

I'm working in Golang and mgo and I would like to delete all the documents in a collection older than a specified date, using _id value. So far I've tried to create a dummy objectId using a struc...
Chickabiddy asked 22/12, 2015 at 9:30

2

I want to upsert a list of record, so I have two choice, one just use one session, another copy a session for every record. So, as my opinion, first method may slower than the second, but will the ...
Eris asked 22/10, 2015 at 7:21

1

Solved

Im having issues with persisting a golang struct in mongodb using mgo. type AN_Track_Log struct { Id bson.ObjectId `bson:"_id,omitempty"` user_session_id_str string `bson:"user_session_id_str"`...
Lauderdale asked 9/10, 2015 at 19:1

1

Solved

I am trying to pass a multiple sort query to the "Sort" parameter of the mgo package (see https://godoc.org/labix.org/v2/mgo#Query.Sort). If the parameters are dynamic (currently held in a slice),...
Santa asked 2/10, 2015 at 13:23

1

Solved

Earlier I posted this question asking about writing custom BSON marshalling/unmarshalling in Go using mgo. Now I've come to test it I think I've hit on a bigger problem. All my structs unmarshal to...
Sumerian asked 17/6, 2015 at 15:23

3

This is my struct definition: type Article struct { Id bson.ObjectId `json:"id" bson:"_id,omitempty"` Title string `json:"title"` Author string `json:"author"` Date string `json:"date"` Tags ...
Swashbuckling asked 26/11, 2013 at 11:12

© 2022 - 2024 — McMap. All rights reserved.