Ejemplo n.º 1
0
func ById(id string) (*models.Release, error) {
	release := &models.Release{}

	if !models.IsValidUUID(id) {
		return release, models.InvalidUUID{id}
	}

	var status *sql.NullString
	var packaging *sql.NullString
	var _type *sql.NullString
	var artistCredit int

	row := models.DB.QueryRow(queryById, id)
	err := row.Scan(&release.Id, &release.Name, &release.Comment, &artistCredit, &status, &packaging, &_type)

	if err != nil {
		return release, err
	}

	if status != nil {
		release.Status = status.String
	}

	if packaging != nil {
		release.Packaging = packaging.String
	}

	if _type != nil {
		release.Type = _type.String
	}

	release.Artists = artist.AllByArtistCredit(artistCredit)

	return release, nil
}
Ejemplo n.º 2
0
func ById(id string) (*models.ReleaseGroup, error) {
	releaseGroup := &models.ReleaseGroup{}

	if !models.IsValidUUID(id) {
		return releaseGroup, models.InvalidUUID{id}
	}

	row := models.DB.QueryRow(queryById, id)
	err := ScanRecord(row, releaseGroup)

	if err == nil {
		releaseGroup.Artists = artist.AllByArtistCredit(releaseGroup.ArtistCredit)
	}

	return releaseGroup, err
}
Ejemplo n.º 3
0
func ById(id string) (*models.Recording, error) {
	recording := &models.Recording{}

	if !models.IsValidUUID(id) {
		return recording, models.InvalidUUID{id}
	}

	var artistCredit int

	row := models.DB.QueryRow(queryById, id)
	err := row.Scan(&recording.Id, &recording.Name, &recording.Comment, &recording.Length, &artistCredit)

	if err != nil {
		return recording, err
	}

	recording.Artists = artist.AllByArtistCredit(artistCredit)

	return recording, nil
}