Skip to content

Automatic synchronization of sql table and filesystem

License

Notifications You must be signed in to change notification settings

mattcarp12/sqlfsync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sqlfsync

Automatically syncronize your SQL database and filesystem. Built using fsnotify and gorm.

Please see the documentation.

Installation

go get github.com/mattcarp12/sqlfsync

Usage

package main

import (
	"github.com/mattcarp12/sqlfsync"
	"gorm.io/driver/sqlite"
	"gorm.io/gorm"
	"time"
)

type MyFile struct {
	ID        uint
	Path      string `sqlfsync:"path"`
	CreatedAt time.Time
}

var done chan bool

func main() {
	db, _ := gorm.Open(sqlite.Open(":memory:"), &gorm.Config{})

	sfs := sqlfsync.New(db)
	sfs.AddWatch("/my/files", &MyFile{})
	defer sfs.Close()

	done = make(chan bool)
	<-done
}

Contributing

Pull requests are encouraged.

License

MIT

About

Automatic synchronization of sql table and filesystem

Resources

License

Stars

Watchers

Forks

Packages

No packages published