That's my struct:
type WorkContract struct {
ID primitive.ObjectID `bson:"_id,omitempty"`
Code string `bson:"code,omitempty"`
Title string `bson:"title,omitempty"`
Description string `bson:"description,omitempty"`
Profile Profile `bson:"profile,omitempty"`
Expertise Expertise `bson:"expertise,omitempty"`
Status Status `bson:"status,omitempty"`
Location Location `bson:"location,omitempty"`
BusinessUnit BusinessUnit `bson:"business_unit,omitempty"`
Customer Customer `bson:"customer,omitempty"`
Offer Offer `bson:"offer,omitempty"`
Skills []Skill `bson:"skills,omitempty"`
DateStart time.Time `bson:"date_start,omitempty"`
DateEnd time.Time `bson:"date_end,omitempty"`
}
Sometimes some of WorkContract fields are empty. I mean:
func generateWorkContract() {
return &model.WorkContract{
Code: workcontract.Code,
Title: workcontract.Title,
Description: workcontract.Description,
Profile: *mapper.profilesMapper.MapToModel(&workcontract.Profile),
Expertise: *mapper.expertisesMapper.MapToModel(&workcontract.Expertise),
Status: model.Status{},
Location: model.Location{},
BusinessUnit: model.BusinessUnit{},
Customer: model.Customer{},
Offer: model.Offer{},
Skills: nil,
DateStart: workcontract.DateStart,
DateEnd: workcontract.DateEnd,
}
}
After having saved above object:
test> db.workcontracts.find();
[
{
"_id":"ObjectId(""62a9a86bf7693c1cd6d15817"")",
"code":"wZ3diYRQ",
"title":"Though we assume the latter, a hilarious chimpanzee's cheetah comes with it the thought that the straightforward lime is a grape.",
"description":"The level melon reveals itself as an excellent wolf to those who look! Some posit the unbiased blueberry to be less than communicative! Seals are successful sheeps!",
"profile":{
"code":"9EoS",
"description":"However, one cannot separate wolfs from encouraging plums. A creative cow without oranges is truly a apple of calm birds. Crocodiles are unassuming giraffes? An elephant is a deer's bird! A pro-active prune without frogs is truly a panda of wonderful goldfishes.",
"enabled":true
},
"expertise":{
"code":"MKjQ9JJu",
"description":"As far as we can estimate, the rats could be said to resemble industrious strawberries. The owl is a bear. Few can name a persistent ant that isn't a quiet deer. Recent controversy aside, brave pigs show us how prunes can be kumquats? If this was somewhat unclear, authors often misinterpret the seal as an endurable pear, when in actuality it feels more like an intelligent rabbit!",
"enabled":false
},
"status":{
"code":"",
"description":"",
"enabled":false
},
"location":{
"code":"",
"description":"",
"enabled":false
},
"business_unit":{
"code":"",
"description":"",
"enabled":false
},
"customer":{
"code":"",
"description":"",
"enabled":false
},
"offer":{
"code":"",
"description":"",
"enabled":false
},
"date_start":"ISODate(""1970-06-19T11:10:59.594Z"")",
"date_end":"ISODate(""1984-08-24T21:22:46.112Z"")"
}
]
Some of the above "empty" field are stored into mongodb.
How could I say to drive to save something like this:
[
{
"_id":"ObjectId(""62a9a86bf7693c1cd6d15817"")",
"code":"wZ3diYRQ",
"title":"Though we assume the latter, a hilarious chimpanzee's cheetah comes with it the thought that the straightforward lime is a grape.",
"description":"The level melon reveals itself as an excellent wolf to those who look! Some posit the unbiased blueberry to be less than communicative! Seals are successful sheeps!",
"profile":{
"code":"9EoS",
"description":"However, one cannot separate wolfs from encouraging plums. A creative cow without oranges is truly a apple of calm birds. Crocodiles are unassuming giraffes? An elephant is a deer's bird! A pro-active prune without frogs is truly a panda of wonderful goldfishes.",
"enabled":true
},
"expertise":{
"code":"MKjQ9JJu",
"description":"As far as we can estimate, the rats could be said to resemble industrious strawberries. The owl is a bear. Few can name a persistent ant that isn't a quiet deer. Recent controversy aside, brave pigs show us how prunes can be kumquats? If this was somewhat unclear, authors often misinterpret the seal as an endurable pear, when in actuality it feels more like an intelligent rabbit!",
"enabled":false
},
"date_start":"ISODate(""1970-06-19T11:10:59.594Z"")",
"date_end":"ISODate(""1984-08-24T21:22:46.112Z"")"
}
]