func (m *MongoManager) BulkUpsert(collectionName string, upsertObj []UpsertObj) (*mgo.BulkResult, error) {
session := m.s.Copy()
defer session.Close()
collection := session.DB(m.dbName).C(collectionName)
bulk := collection.Bulk()
var upsertOp []interface{}
for _, value := range upsertObj {
now := time.Now()
value.Data.GetMongoBase().UpdatedAt = now.Unix()
upsertOp = append(upsertOp, value.Query, value.Data)
}
return bulk.Run()
}
Where upsertObj is a simple struct of:
type UpsertObj struct {
Query bson.M
Data AbstractBase
}
I'm trying to upsert 5-10 documents (I need to be able to upsert around 250-350) but keep getting this error message
closing: read tcp ip:port->ip:port: read: connection reset by peer (abend=true)
I'm clueless of what I'm doing wrong, (this is a working server in which we use all the time to do way more robustic actions)
Any thoughts?
Thanks!