Documentation ¶
Overview ¶
Package sqlite provides a reference implementation of a Bernard datastore. Other SQL implementations should ideally borrow from this code as the SQL should be compatible with other drivers as well.
Index ¶
- Variables
- type Datastore
- func (store *Datastore) FullSync(drive ds.Drive, folders []ds.Folder, files []ds.File) (err error)
- func (store *Datastore) NewDifferencesHook() (bernard.Hook, *Difference)
- func (store *Datastore) PageToken(driveID string) (string, error)
- func (store *Datastore) PartialSync(drive ds.Drive, changedFolders []ds.Folder, changedFiles []ds.File, ...) error
- type Difference
- type FileDifference
- type FolderDifference
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidStatement = fmt.Errorf("invalid statement: %w", ds.ErrDatabase)
ErrInvalidStatement occurs when the SQL statement is not compatible with the underlying driver or when the database is not initialised with tables yet.
var ErrTransaction = fmt.Errorf("transaction: %w", ds.ErrDatabase)
ErrTransaction can have values begin or commit, and indicates an error when beginning or commiting a transaction
Functions ¶
This section is empty.
Types ¶
type Datastore ¶
Datastore holds our SQLite3 database connection and implements the Bernard Datastore interface.
func (*Datastore) NewDifferencesHook ¶
func (store *Datastore) NewDifferencesHook() (bernard.Hook, *Difference)
NewDifferencesHook creates a Hook which checks which files and folders have been added, changed or removed.
Like all hooks, the corresponding output struct is only updated when the hook is executed.
func (*Datastore) PartialSync ¶
func (store *Datastore) PartialSync(drive ds.Drive, changedFolders []ds.Folder, changedFiles []ds.File, removedIDs []string) error
PartialSync synchronises the provided changes to the datastore.
1. Update the pageToken and (if applicable) the name of the Shared Drive.
2. Process changed folders with UPSERT.
3. Process changed folders with UPSERT.
4. Remove any items of which the IDs match with the removedIDs slice.
type Difference ¶
type Difference struct { AddedFiles []ds.File ChangedFiles []FileDifference RemovedFiles []ds.File AddedFolders []ds.Folder ChangedFolders []FolderDifference RemovedFolders []ds.Folder }
The Difference contains all added, changes and removed files and folders between two states.