mgo
mgo copied to clipboard
Implement "omitalways" tag to allow decode yet prevent encode.
A developer may wish to decode or otherwise assign to a struct field but not re-encode. For example, a MongoDB document struct with a struct pointer inside for relationships:
type User struct {
Email string `bson:"email"`
Sessions []Session `bson:"sessions,omitalways"`
}
This is accomplished via the following set of implementations:
- Implement flag in
fieldInfo
struct. - Implement flag detection and assignment to
fieldInfo
struct. - Implement skip-encode on flag true.
- Implement documentation and examples.