Documentation
¶
Index ¶
- Variables
- type AuthToken
- type Branch
- type Collection
- type CollectionShare
- type Document
- type PublicShare
- type Section
- type SnapshottedCollection
- type SnapshottedDocument
- type SnapshottedSection
- type SnapshottedUser
- type Store
- func (s *Store) CanReadCollection(ctx context.Context, userID model.UserID, collectionID model.CollectionID) (bool, error)
- func (s *Store) CanReadDocument(ctx context.Context, userID model.UserID, documentID model.DocumentID) (bool, error)
- func (s *Store) CanWriteCollection(ctx context.Context, userID model.UserID, collectionID model.CollectionID) (bool, error)
- func (s *Store) CanWriteDocument(ctx context.Context, userID model.UserID, documentID model.DocumentID) (bool, error)
- func (s *Store) CountReadableDocuments(ctx context.Context, userID model.UserID) (int64, error)
- func (s *Store) CreateAuthToken(ctx context.Context, token model.AuthToken) error
- func (s *Store) CreateCollection(ctx context.Context, ownerID model.UserID, label string) (model.PersistedCollection, error)
- func (s *Store) CreateCollectionShare(ctx context.Context, collectionID model.CollectionID, userID model.UserID, ...) (model.PersistedCollectionShare, error)
- func (s *Store) DeleteAuthToken(ctx context.Context, tokenID model.AuthTokenID) error
- func (s *Store) DeleteCollection(ctx context.Context, id model.CollectionID) error
- func (s *Store) DeleteCollectionShare(ctx context.Context, shareID model.CollectionShareID) error
- func (s *Store) DeleteDocumentByID(ctx context.Context, ids ...model.DocumentID) error
- func (s *Store) DeleteDocumentBySource(ctx context.Context, ownerID model.UserID, source *url.URL) error
- func (s *Store) DeletePublicShare(ctx context.Context, id model.PublicShareID) error
- func (s *Store) FindAuthToken(ctx context.Context, token string) (model.AuthToken, error)
- func (s *Store) FindOrCreateUser(ctx context.Context, provider, subject string) (model.User, error)
- func (s *Store) FindPublicShareByToken(ctx context.Context, token string) (model.PersistedPublicShare, error)
- func (s *Store) GenerateSnapshot(ctx context.Context) (io.ReadCloser, error)
- func (s *Store) GetCollectionByID(ctx context.Context, id model.CollectionID, full bool) (model.PersistedCollection, error)
- func (s *Store) GetCollectionShares(ctx context.Context, collectionID model.CollectionID) ([]model.PersistedCollectionShare, error)
- func (s *Store) GetCollectionStats(ctx context.Context, id model.CollectionID) (*model.CollectionStats, error)
- func (s *Store) GetDocumentByID(ctx context.Context, id model.DocumentID) (model.PersistedDocument, error)
- func (s *Store) GetPublicShareByID(ctx context.Context, id model.PublicShareID) (model.PersistedPublicShare, error)
- func (s *Store) GetSectionByID(ctx context.Context, id model.SectionID) (model.Section, error)
- func (s *Store) GetSectionsByIDs(ctx context.Context, ids []model.SectionID) (map[model.SectionID]model.Section, error)
- func (s *Store) GetUserAuthTokens(ctx context.Context, userID model.UserID) ([]model.AuthToken, error)
- func (s *Store) GetUserByID(ctx context.Context, userID model.UserID) (model.User, error)
- func (s *Store) QueryCollections(ctx context.Context, opts port.QueryCollectionsOptions) ([]model.PersistedCollection, error)
- func (s *Store) QueryDocuments(ctx context.Context, opts port.QueryDocumentsOptions) ([]model.PersistedDocument, int64, error)
- func (s *Store) QueryDocumentsByCollectionID(ctx context.Context, collectionID model.CollectionID, ...) ([]model.PersistedDocument, int64, error)
- func (s *Store) QueryPublicShares(ctx context.Context, opts port.QueryPublicSharesOptions) ([]model.PersistedPublicShare, error)
- func (s *Store) QueryUserReadableCollections(ctx context.Context, userID model.UserID, opts port.QueryCollectionsOptions) ([]model.PersistedCollection, int64, error)
- func (s *Store) QueryUserReadableDocuments(ctx context.Context, userID model.UserID, opts port.QueryDocumentsOptions) ([]model.PersistedDocument, int64, error)
- func (s *Store) QueryUserWritableCollections(ctx context.Context, userID model.UserID, opts port.QueryCollectionsOptions) ([]model.PersistedCollection, int64, error)
- func (s *Store) QueryUserWritableDocuments(ctx context.Context, userID model.UserID, opts port.QueryDocumentsOptions) ([]model.PersistedDocument, int64, error)
- func (s *Store) QueryUsers(ctx context.Context, opts port.QueryUsersOptions) ([]model.User, error)
- func (s *Store) RestoreSnapshot(ctx context.Context, r io.Reader) error
- func (s *Store) SaveDocuments(ctx context.Context, documents ...model.OwnedDocument) error
- func (s *Store) SavePublicShare(ctx context.Context, publicShare model.OwnedPublicShare) (model.PersistedPublicShare, error)
- func (s *Store) SaveUser(ctx context.Context, user model.User) error
- func (s *Store) SectionExists(ctx context.Context, id model.SectionID) (bool, error)
- func (s *Store) UpdateCollection(ctx context.Context, id model.CollectionID, updates port.CollectionUpdates) (model.PersistedCollection, error)
- type User
- type UserPreferences
- type UserRole
Constants ¶
This section is empty.
Variables ¶
var (
ErrMissingSource = errors.New("missing source")
)
Functions ¶
This section is empty.
Types ¶
type Collection ¶
type CollectionShare ¶
type CollectionShare struct {
}
CollectionShare is the GORM model for collection shares.
type Document ¶
type Document struct {
ID string `gorm:"primaryKey;autoIncrement:false"`
ETag string `gorm:"index"`
CreatedAt time.Time
UpdatedAt time.Time
Owner *User
OwnerID string
Source string `gorm:"unique;not null;index"`
Sections []*Section `gorm:"constraint:OnDelete:CASCADE"`
Collections []*Collection `gorm:"many2many:documents_collections;"`
Content []byte
}
type PublicShare ¶
type PublicShare struct {
}
type Section ¶
type Section struct {
ID string `gorm:"primaryKey;autoIncrement:false"`
CreatedAt time.Time
UpdatedAt time.Time
Document *Document
DocumentID string
Parent *Section
ParentID *string
// Fixed: Self-referencing relationship should only use ParentID as foreign key
// ParentID references the ID field of the same Section table
Sections []*Section `gorm:"foreignKey:ParentID;references:ID;constraint:OnDelete:CASCADE"`
Branch *Branch
Level uint
Start int
End int
}
type SnapshottedCollection ¶
type SnapshottedDocument ¶
type SnapshottedDocument struct {
ID string
Owner SnapshottedUser
Source string
ETag string
Content []byte
Collections []SnapshottedCollection
Sections []SnapshottedSection
}
type SnapshottedSection ¶
type SnapshottedUser ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) CanReadCollection ¶
func (s *Store) CanReadCollection(ctx context.Context, userID model.UserID, collectionID model.CollectionID) (bool, error)
CanReadCollection implements port.DocumentStore.
func (*Store) CanReadDocument ¶
func (s *Store) CanReadDocument(ctx context.Context, userID model.UserID, documentID model.DocumentID) (bool, error)
CanReadDocument implements port.DocumentStore.
func (*Store) CanWriteCollection ¶
func (s *Store) CanWriteCollection(ctx context.Context, userID model.UserID, collectionID model.CollectionID) (bool, error)
CanWriteCollection implements port.DocumentStore.
func (*Store) CanWriteDocument ¶
func (s *Store) CanWriteDocument(ctx context.Context, userID model.UserID, documentID model.DocumentID) (bool, error)
CanWriteDocument implements port.DocumentStore.
func (*Store) CountReadableDocuments ¶
CountReadableDocuments implements port.DocumentStore.
func (*Store) CreateAuthToken ¶
CreateAuthToken implements port.UserStore.
func (*Store) CreateCollection ¶
func (s *Store) CreateCollection(ctx context.Context, ownerID model.UserID, label string) (model.PersistedCollection, error)
CreateCollection implements port.DocumentStore.
func (*Store) CreateCollectionShare ¶
func (s *Store) CreateCollectionShare(ctx context.Context, collectionID model.CollectionID, userID model.UserID, level model.CollectionShareLevel) (model.PersistedCollectionShare, error)
CreateCollectionShare implements port.DocumentStore.
func (*Store) DeleteAuthToken ¶
DeleteAuthToken implements port.UserStore.
func (*Store) DeleteCollection ¶
DeleteCollection implements port.DocumentStore.
func (*Store) DeleteCollectionShare ¶
DeleteCollectionShare implements port.DocumentStore.
func (*Store) DeleteDocumentByID ¶
DeleteDocumentByID implements port.DocumentStore.
func (*Store) DeleteDocumentBySource ¶
func (s *Store) DeleteDocumentBySource(ctx context.Context, ownerID model.UserID, source *url.URL) error
DeleteDocumentBySource implements port.DocumentStore.
func (*Store) DeletePublicShare ¶
DeletePublicShare implements port.PublicShareStore.
func (*Store) FindAuthToken ¶
FindAuthToken implements port.UserStore.
func (*Store) FindOrCreateUser ¶
FindOrCreateUser implements port.UserStore.
func (*Store) FindPublicShareByToken ¶
func (s *Store) FindPublicShareByToken(ctx context.Context, token string) (model.PersistedPublicShare, error)
FindPublicShareByToken implements port.PublicShareStore.
func (*Store) GenerateSnapshot ¶
GenerateSnapshot implements backup.Snapshotable.
func (*Store) GetCollectionByID ¶
func (s *Store) GetCollectionByID(ctx context.Context, id model.CollectionID, full bool) (model.PersistedCollection, error)
GetCollectionByID implements port.DocumentStore.
func (*Store) GetCollectionShares ¶
func (s *Store) GetCollectionShares(ctx context.Context, collectionID model.CollectionID) ([]model.PersistedCollectionShare, error)
GetCollectionShares implements port.DocumentStore.
func (*Store) GetCollectionStats ¶
func (s *Store) GetCollectionStats(ctx context.Context, id model.CollectionID) (*model.CollectionStats, error)
GetCollectionStats implements port.DocumentStore.
func (*Store) GetDocumentByID ¶
func (s *Store) GetDocumentByID(ctx context.Context, id model.DocumentID) (model.PersistedDocument, error)
GetDocumentByID implements port.DocumentStore.
func (*Store) GetPublicShareByID ¶
func (s *Store) GetPublicShareByID(ctx context.Context, id model.PublicShareID) (model.PersistedPublicShare, error)
GetPublicShareByID implements port.PublicShareStore.
func (*Store) GetSectionByID ¶
GetSectionByID implements port.DocumentStore.
func (*Store) GetSectionsByIDs ¶
func (s *Store) GetSectionsByIDs(ctx context.Context, ids []model.SectionID) (map[model.SectionID]model.Section, error)
GetSectionsByIDs implements port.DocumentStore.
func (*Store) GetUserAuthTokens ¶
func (s *Store) GetUserAuthTokens(ctx context.Context, userID model.UserID) ([]model.AuthToken, error)
GetUserAuthTokens implements port.UserStore.
func (*Store) GetUserByID ¶
GetUserByID implements port.UserStore.
func (*Store) QueryCollections ¶
func (s *Store) QueryCollections(ctx context.Context, opts port.QueryCollectionsOptions) ([]model.PersistedCollection, error)
QueryCollections implements port.DocumentStore.
func (*Store) QueryDocuments ¶
func (s *Store) QueryDocuments(ctx context.Context, opts port.QueryDocumentsOptions) ([]model.PersistedDocument, int64, error)
QueryDocuments implements port.DocumentStore.
func (*Store) QueryDocumentsByCollectionID ¶
func (s *Store) QueryDocumentsByCollectionID(ctx context.Context, collectionID model.CollectionID, opts port.QueryDocumentsOptions) ([]model.PersistedDocument, int64, error)
QueryDocumentsByCollectionID implements port.DocumentStore.
func (*Store) QueryPublicShares ¶
func (s *Store) QueryPublicShares(ctx context.Context, opts port.QueryPublicSharesOptions) ([]model.PersistedPublicShare, error)
QueryPublicShares implements port.PublicShareStore.
func (*Store) QueryUserReadableCollections ¶
func (s *Store) QueryUserReadableCollections(ctx context.Context, userID model.UserID, opts port.QueryCollectionsOptions) ([]model.PersistedCollection, int64, error)
QueryUserReadableCollections implements port.DocumentStore.
func (*Store) QueryUserReadableDocuments ¶
func (s *Store) QueryUserReadableDocuments(ctx context.Context, userID model.UserID, opts port.QueryDocumentsOptions) ([]model.PersistedDocument, int64, error)
QueryUserReadableDocuments implements port.DocumentStore.
func (*Store) QueryUserWritableCollections ¶
func (s *Store) QueryUserWritableCollections(ctx context.Context, userID model.UserID, opts port.QueryCollectionsOptions) ([]model.PersistedCollection, int64, error)
QueryUserWritableCollections implements port.DocumentStore.
func (*Store) QueryUserWritableDocuments ¶
func (s *Store) QueryUserWritableDocuments(ctx context.Context, userID model.UserID, opts port.QueryDocumentsOptions) ([]model.PersistedDocument, int64, error)
QueryUserWritableDocuments implements port.DocumentStore.
func (*Store) QueryUsers ¶
QueryUsers implements port.UserStore.
func (*Store) RestoreSnapshot ¶
RestoreSnapshot implements backup.Snapshotable.
func (*Store) SaveDocuments ¶
SaveDocuments implements port.DocumentStore.
func (*Store) SavePublicShare ¶
func (s *Store) SavePublicShare(ctx context.Context, publicShare model.OwnedPublicShare) (model.PersistedPublicShare, error)
SavePublicShare implements port.PublicShareStore.
func (*Store) SectionExists ¶
SectionExists implements port.DocumentStore.
func (*Store) UpdateCollection ¶
func (s *Store) UpdateCollection(ctx context.Context, id model.CollectionID, updates port.CollectionUpdates) (model.PersistedCollection, error)
UpdateCollection implements port.DocumentStore.
type User ¶
type User struct {
ID string `gorm:"primaryKey;autoIncrement:false"`
CreatedAt time.Time
UpdatedAt time.Time
Subject string `gorm:"index"`
Provider string `gorm:"index"`
DisplayName string
Email string `gorm:"unique"`
AuthTokens []*AuthToken `gorm:"foreignKey:OwnerID;constraint:OnDelete:CASCADE;"`
Documents []*Document `gorm:"foreignKey:OwnerID;constraint:OnDelete:CASCADE;"`
Collections []*Collection `gorm:"foreignKey:OwnerID;constraint:OnDelete:CASCADE;"`
Roles []*UserRole `gorm:"constraint:OnDelete:CASCADE;"`
Active bool
Preferences *UserPreferences `gorm:"foreignKey:UserID;constraint:OnDelete:CASCADE"`
}
type UserPreferences ¶
type UserPreferences struct {
ID uint `gorm:"primaryKey"`
UserID string `gorm:"unique;index"`
DarkMode bool
}
UserPreference is a separate table for storing user preferences