Skip to content

Commit

Permalink
added FilterPropertiesByResultOption to DataStoreMetaInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
jonbarrow committed Oct 30, 2023
1 parent fc17fb6 commit 352b637
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions datastore/types/datastore_meta_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,30 @@ func (dataStoreMetaInfo *DataStoreMetaInfo) FormatToString(indentationLevel int)
return b.String()
}

// FilterPropertiesByResultOption zeroes out certain struct properties based on the input flags
func (dataStoreMetaInfo *DataStoreMetaInfo) FilterPropertiesByResultOption(resultOption uint8) {
// * This is kind of backwards
// *
// * This method assumes all struct data exists
// * by default. This is done in order to simplify
// * database calls by just querying for all fields
// * at once. Therefore, instead of the ResultOption
// * flags being used to conditionally ADD properties,
// * it's used to conditionally REMOVE them

if resultOption&0x1 == 0 {
dataStoreMetaInfo.Tags = make([]string, 0)
}

if resultOption&0x2 == 0 {
dataStoreMetaInfo.Ratings = make([]*DataStoreRatingInfoWithSlot, 0)
}

if resultOption&0x4 == 0 {
dataStoreMetaInfo.MetaBinary = make([]byte, 0)
}
}

// NewDataStoreMetaInfo returns a new DataStoreMetaInfo
func NewDataStoreMetaInfo() *DataStoreMetaInfo {
return &DataStoreMetaInfo{
Expand Down

0 comments on commit 352b637

Please sign in to comment.