Skip to content

Latest commit

 

History

History
51 lines (35 loc) · 869 Bytes

README.md

File metadata and controls

51 lines (35 loc) · 869 Bytes

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