Documentation
¶
Index ¶
- Variables
- type Config
- type FxResult
- type SelectFilter
- type Service
- func (s *Service) Clean(ctx context.Context) error
- func (s *Service) Get(userID string, filter ...SelectFilter) (models.Device, error)
- func (s *Service) GetByToken(token string) (models.Device, error)
- func (s *Service) Insert(userID string, device *models.Device) error
- func (s *Service) Remove(userID string, filter ...SelectFilter) error
- func (s *Service) Select(userID string, filter ...SelectFilter) ([]models.Device, error)
- func (s *Service) UpdateLastSeen(deviceId string) error
- func (s *Service) UpdatePushToken(deviceId string, token string) error
- type ServiceParams
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNotFound = gorm.ErrRecordNotFound ErrInvalidFilter = errors.New("invalid filter") ErrMoreThanOne = errors.New("more than one record") )
View Source
var (
ErrInvalidUser = errors.New("invalid user")
)
Functions ¶
This section is empty.
Types ¶
type SelectFilter ¶
type SelectFilter func(*selectFilter)
func WithID ¶
func WithID(id string) SelectFilter
func WithToken ¶
func WithToken(token string) SelectFilter
func WithUserID ¶
func WithUserID(userID string) SelectFilter
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(params ServiceParams) *Service
func (*Service) Get ¶
Get returns a single device based on the provided filters for a specific user. It ensures that the filter includes the user's ID. If no device matches the criteria, it returns ErrNotFound. If more than one device matches, it returns ErrMoreThanOne.
func (*Service) GetByToken ¶ added in v1.18.0
GetByToken returns a device by token.
This method is used to retrieve a device by its auth token. If the device does not exist, it returns ErrNotFound.
func (*Service) Remove ¶ added in v1.18.0
func (s *Service) Remove(userID string, filter ...SelectFilter) error
Remove removes devices for a specific user that match the provided filters. It ensures that the filter includes the user's ID.
func (*Service) Select ¶
Select returns a list of devices for a specific user that match the provided filters.
func (*Service) UpdateLastSeen ¶
Click to show internal directories.
Click to hide internal directories.