Documentation ¶
Index ¶
- Variables
- type FakeRepository
- func (r *FakeRepository) BookmarkAddMany(bookmarks []bookmark.Bookmark) (int64, error)
- func (r *FakeRepository) BookmarkIsURLRegistered(userUUID, url string) (bool, error)
- func (r *FakeRepository) BookmarkIsURLRegisteredToAnotherUID(userUUID, url, uid string) (bool, error)
- func (r *FakeRepository) BookmarkUpsertMany(bookmarks []bookmark.Bookmark) (int64, error)
- type OnConflictStrategy
- type Repository
- type Service
- type Status
- type Visibility
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrOnConflictStrategyInvalid error = errors.New("invalid value for on-conflict strategy")
)
View Source
var (
ErrVisibilityInvalid error = errors.New("invalid value for visibility")
)
Functions ¶
This section is empty.
Types ¶
type FakeRepository ¶
func (*FakeRepository) BookmarkAddMany ¶
func (r *FakeRepository) BookmarkAddMany(bookmarks []bookmark.Bookmark) (int64, error)
func (*FakeRepository) BookmarkIsURLRegistered ¶
func (r *FakeRepository) BookmarkIsURLRegistered(userUUID, url string) (bool, error)
func (*FakeRepository) BookmarkIsURLRegisteredToAnotherUID ¶
func (r *FakeRepository) BookmarkIsURLRegisteredToAnotherUID(userUUID, url, uid string) (bool, error)
func (*FakeRepository) BookmarkUpsertMany ¶
func (r *FakeRepository) BookmarkUpsertMany(bookmarks []bookmark.Bookmark) (int64, error)
type OnConflictStrategy ¶
type OnConflictStrategy string
OnConflictStrategy represents the strategy to apply when importing data that is already present in the repository.
const ( // Overwrite existing data with imported data. OnConflictOverwrite OnConflictStrategy = "overwrite" // Keep existing data and ignore new data. OnConflictKeepExisting OnConflictStrategy = "keep" )
type Repository ¶
type Repository interface { // BookmarkAddMany adds a collection of new bookmarks. BookmarkAddMany(bookmarks []bookmark.Bookmark) (int64, error) // BookmarkUpsertMany adds a collection of new bookmarks and updates // existing bookmarks in case of conflict. BookmarkUpsertMany(bookmarks []bookmark.Bookmark) (int64, error) }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles bookmark import operations.
func NewService ¶
func NewService(r Repository) *Service
NewService initializes and returns a new Service.
func (*Service) ImportFromNetscapeDocument ¶
func (s *Service) ImportFromNetscapeDocument(userUUID string, document *netscape.Document, visibility Visibility, overwrite OnConflictStrategy) (Status, error)
ImportFromNetscapeDocument performs a bulk import from a Netscape bookmark export.
The import will ignore: - duplicate bookmarks for a given URL; only the first entry will be imported; - bookmarks with missing or invalid values for required fields, such as the Title and URL.
type Status ¶
type Status struct { // Invalid entries that did not correspond to valid bookmark entries (URL, Title). Invalid int // New bookmarks, or existing bookmarks that were updated. NewOrUpdated int // Skipped bookmarks (existing bookmarks were kept). Skipped int // contains filtered or unexported fields }
Status provides details about the imported data.
type Visibility ¶
type Visibility string
Visibility defines how bookmarks are imported.
const ( // Keep the existing value for imported bookmarks; if missing, // bookmarks will be imported as public. VisibilityDefault Visibility = "default" // Import all bookmarks as private. VisibilityPrivate Visibility = "private" // Import all bookmarks as public. VisibilityPublic Visibility = "public" )
Click to show internal directories.
Click to hide internal directories.