Пример #1
0
func (m TestIdentityRepository) List(ctx context.Context) (*app.IdentityArray, error) {
	rows := []account.Identity{*m.Identity}

	res := app.IdentityArray{}
	res.Data = make([]*app.IdentityData, len(rows))
	for index, value := range rows {
		ident := value.ConvertIdentityFromModel()
		res.Data[index] = ident.Data
	}
	return &res, nil
}
Пример #2
0
// List return all user identities
func (m *GormIdentityRepository) List(ctx context.Context) (*app.IdentityArray, error) {
	defer goa.MeasureSince([]string{"goa", "db", "identity", "list"}, time.Now())
	var rows []Identity

	err := m.db.Model(&Identity{}).Order("username").Find(&rows).Error
	if err != nil && err != gorm.ErrRecordNotFound {
		return nil, errors.WithStack(err)
	}
	res := app.IdentityArray{}
	res.Data = make([]*app.IdentityData, len(rows))
	for index, value := range rows {
		ident := value.ConvertIdentityFromModel()
		res.Data[index] = ident.Data
	}

	log.Debug(ctx, map[string]interface{}{
		"pkg":          "identity",
		"identityList": &res,
	}, "Identity List executed successfully!")

	return &res, nil
}