func ToJSON(reader models.PerformerReader, performer *models.Performer) (*jsonschema.Performer, error) {
	newPerformerJSON := jsonschema.Performer{
		IgnoreAutoTag: performer.IgnoreAutoTag,
		CreatedAt:     json.JSONTime{Time: performer.CreatedAt.Timestamp},
		UpdatedAt:     json.JSONTime{Time: performer.UpdatedAt.Timestamp},
	}

	if performer.Name.Valid {
		newPerformerJSON.Name = performer.Name.String
	}
	if performer.Gender.Valid {
		newPerformerJSON.Gender = performer.Gender.String
	}
	if performer.URL.Valid {
		newPerformerJSON.URL = performer.URL.String
	}
	if performer.Birthdate.Valid {
		newPerformerJSON.Birthdate = utils.GetYMDFromDatabaseDate(performer.Birthdate.String)
	}
	if performer.Ethnicity.Valid {
		newPerformerJSON.Ethnicity = performer.Ethnicity.String
	}
	if performer.Country.Valid {
		newPerformerJSON.Country = performer.Country.String
	}
	if performer.EyeColor.Valid {
		newPerformerJSON.EyeColor = performer.EyeColor.String
	}
	if performer.Height.Valid {
		newPerformerJSON.Height = performer.Height.String
	}
	if performer.Measurements.Valid {
		newPerformerJSON.Measurements = performer.Measurements.String
	}
	if performer.FakeTits.Valid {
		newPerformerJSON.FakeTits = performer.FakeTits.String
	}
	if performer.CareerLength.Valid {
		newPerformerJSON.CareerLength = performer.CareerLength.String
	}
	if performer.Tattoos.Valid {
		newPerformerJSON.Tattoos = performer.Tattoos.String
	}
	if performer.Piercings.Valid {
		newPerformerJSON.Piercings = performer.Piercings.String
	}
	if performer.Aliases.Valid {
		newPerformerJSON.Aliases = performer.Aliases.String
	}
	if performer.Twitter.Valid {
		newPerformerJSON.Twitter = performer.Twitter.String
	}
	if performer.Instagram.Valid {
		newPerformerJSON.Instagram = performer.Instagram.String
	}
	if performer.Favorite.Valid {
		newPerformerJSON.Favorite = performer.Favorite.Bool
	}
	if performer.Rating.Valid {
		newPerformerJSON.Rating = int(performer.Rating.Int64)
	}
	if performer.Details.Valid {
		newPerformerJSON.Details = performer.Details.String
	}
	if performer.DeathDate.Valid {
		newPerformerJSON.DeathDate = utils.GetYMDFromDatabaseDate(performer.DeathDate.String)
	}
	if performer.HairColor.Valid {
		newPerformerJSON.HairColor = performer.HairColor.String
	}
	if performer.Weight.Valid {
		newPerformerJSON.Weight = int(performer.Weight.Int64)
	}

	image, err := reader.GetImage(performer.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting performers image: %v", err)
	}

	if len(image) > 0 {
		newPerformerJSON.Image = utils.GetBase64StringFromData(image)
	}

	stashIDs, _ := reader.GetStashIDs(performer.ID)
	var ret []models.StashID
	for _, stashID := range stashIDs {
		newJoin := models.StashID{
			StashID:  stashID.StashID,
			Endpoint: stashID.Endpoint,
		}
		ret = append(ret, newJoin)
	}

	newPerformerJSON.StashIDs = ret

	return &newPerformerJSON, nil
}
// ToJSON converts a Performer object into its JSON equivalent.
ToJSON converts a Performer object into its JSON equivalent.
// ToJSON converts a Performer object into its JSON equivalent .
func ToJSON(reader models.PerformerReader, performer *models.Performer) (*jsonschema.Performer, error) {
	newPerformerJSON := jsonschema.Performer{
		IgnoreAutoTag: performer.IgnoreAutoTag,
		CreatedAt:     json.JSONTime{Time: performer.CreatedAt.Timestamp},
		UpdatedAt:     json.JSONTime{Time: performer.UpdatedAt.Timestamp},
	}
	if performer.Name.Valid {
		newPerformerJSON.Name = performer.Name.String
	}
	if performer.Gender.Valid {
		newPerformerJSON.Gender = performer.Gender.String
	}
	if performer.URL.Valid {
		newPerformerJSON.URL = performer.URL.String
	}
	if performer.Birthdate.Valid {
		newPerformerJSON.Birthdate = utils.GetYMDFromDatabaseDate(performer.Birthdate.String)
	}
	if performer.Ethnicity.Valid {
		newPerformerJSON.Ethnicity = performer.Ethnicity.String
	}
	if performer.Country.Valid {
		newPerformerJSON.Country = performer.Country.String
	}
	if performer.EyeColor.Valid {
		newPerformerJSON.EyeColor = performer.EyeColor.String
	}
	if performer.Height.Valid {
		newPerformerJSON.Height = performer.Height.String
	}
	if performer.Measurements.Valid {
		newPerformerJSON.Measurements = performer.Measurements.String
	}
	if performer.FakeTits.Valid {
		newPerformerJSON.FakeTits = performer.FakeTits.String
	}
	if performer.CareerLength.Valid {
		newPerformerJSON.CareerLength = performer.CareerLength.String
	}
	if performer.Tattoos.Valid {
		newPerformerJSON.Tattoos = performer.Tattoos.String
	}
	if performer.Piercings.Valid {
		newPerformerJSON.Piercings = performer.Piercings.String
	}
	if performer.Aliases.Valid {
		newPerformerJSON.Aliases = performer.Aliases.String
	}
	if performer.Twitter.Valid {
		newPerformerJSON.Twitter = performer.Twitter.String
	}
	if performer.Instagram.Valid {
		newPerformerJSON.Instagram = performer.Instagram.String
	}
	if performer.Favorite.Valid {
		newPerformerJSON.Favorite = performer.Favorite.Bool
	}
	if performer.Rating.Valid {
		newPerformerJSON.Rating = int(performer.Rating.Int64)
	}
	if performer.Details.Valid {
		newPerformerJSON.Details = performer.Details.String
	}
	if performer.DeathDate.Valid {
		newPerformerJSON.DeathDate = utils.GetYMDFromDatabaseDate(performer.DeathDate.String)
	}
	if performer.HairColor.Valid {
		newPerformerJSON.HairColor = performer.HairColor.String
	}
	if performer.Weight.Valid {
		newPerformerJSON.Weight = int(performer.Weight.Int64)
	}
	image, err := reader.GetImage(performer.ID)
	if err != nil {
		return nil, fmt.Errorf("error getting performers image: %v", err)
	}
	if len(image) > 0 {
		newPerformerJSON.Image = utils.GetBase64StringFromData(image)
	}
	stashIDs, _ := reader.GetStashIDs(performer.ID)
	var ret []models.StashID
	for _, stashID := range stashIDs {
		newJoin := models.StashID{
			StashID:  stashID.StashID,
			Endpoint: stashID.Endpoint,
		}
		ret = append(ret, newJoin)
	}
	newPerformerJSON.StashIDs = ret
	return &newPerformerJSON, nil
}
func ToJSON ( reader models . PerformerReader , performer * models . Performer ) ( * jsonschema . Performer , error ) { newPerformerJSON := jsonschema . Performer { IgnoreAutoTag : performer . IgnoreAutoTag , CreatedAt : json . JSONTime { Time : performer . CreatedAt . Timestamp } , UpdatedAt : json . JSONTime { Time : performer . UpdatedAt . Timestamp } , } if performer . Name . Valid { newPerformerJSON . Name = performer . Name . String } if performer . Gender . Valid { newPerformerJSON . Gender = performer . Gender . String } if performer . URL . Valid { newPerformerJSON . URL = performer . URL . String } if performer . Birthdate . Valid { newPerformerJSON . Birthdate = utils . GetYMDFromDatabaseDate ( performer . Birthdate . String ) } if performer . Ethnicity . Valid { newPerformerJSON . Ethnicity = performer . Ethnicity . String } if performer . Country . Valid { newPerformerJSON . Country = performer . Country . String } if performer . EyeColor . Valid { newPerformerJSON . EyeColor = performer . EyeColor . String } if performer . Height . Valid { newPerformerJSON . Height = performer . Height . String } if performer . Measurements . Valid { newPerformerJSON . Measurements = performer . Measurements . String } if performer . FakeTits . Valid { newPerformerJSON . FakeTits = performer . FakeTits . String } if performer . CareerLength . Valid { newPerformerJSON . CareerLength = performer . CareerLength . String } if performer . Tattoos . Valid { newPerformerJSON . Tattoos = performer . Tattoos . String } if performer . Piercings . Valid { newPerformerJSON . Piercings = performer . Piercings . String } if performer . Aliases . Valid { newPerformerJSON . Aliases = performer . Aliases . String } if performer . Twitter . Valid { newPerformerJSON . Twitter = performer . Twitter . String } if performer . Instagram . Valid { newPerformerJSON . Instagram = performer . Instagram . String } if performer . Favorite . Valid { newPerformerJSON . Favorite = performer . Favorite . Bool } if performer . Rating . Valid { newPerformerJSON . Rating = int ( performer . Rating . Int64 ) } if performer . Details . Valid { newPerformerJSON . Details = performer . Details . String } if performer . DeathDate . Valid { newPerformerJSON . DeathDate = utils . GetYMDFromDatabaseDate ( performer . DeathDate . String ) } if performer . HairColor . Valid { newPerformerJSON . HairColor = performer . HairColor . String } if performer . Weight . Valid { newPerformerJSON . Weight = int ( performer . Weight . Int64 ) } image , err := reader . GetImage ( performer . ID ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if len ( image ) > 0 { newPerformerJSON . Image = utils . GetBase64StringFromData ( image ) } stashIDs , _ := reader . GetStashIDs ( performer . ID ) var ret [ ] models . StashID for _ , stashID := range stashIDs { newJoin := models . StashID { StashID : stashID . StashID , Endpoint : stashID . Endpoint , } ret = append ( ret , newJoin ) } newPerformerJSON . StashIDs = ret return & newPerformerJSON , nil }
ToJSON converts a Performer object into its JSON equivalent.
ToJSON converts a Performer object into its JSON equivalent .