mgo icon indicating copy to clipboard operation
mgo copied to clipboard

Implement "omitalways" tag to allow decode yet prevent encode.

Open Nifty255 opened this issue 4 years ago • 0 comments

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.

Nifty255 avatar Apr 23 '20 05:04 Nifty255