Skip to content

FoxComm/gizmo

Repository files navigation

Gizmo

Gizmo is a library that allows for the creation of versioned, view-aware objects written in a relational style. It is a simple, safe, and productive framework for creating content that will be present data different in different situations and is automatically versioned on every change.

Getting Started

  1. Download and install it:

    $ go get github.com/FoxComm/gizmo
  2. Run the database migrations:

    $ gizmo setup
  3. Import gizmo to your code:

    import "github.com/FoxComm/gizmo"
  4. Add gizmo.EntityObject to the struct you want to save:

    type Product struct {
      gizmo.EntityObject
    
      Title       string
      Description string
    }
  5. Create Manager and connect to your database:

    dbHost := "127.0.0.1"
    dbName := "gizmo"
    dbUser := "gizmo"
    dbPassword := "I<3Gizmo"
    
    mgr, err := gizmo.NewManager(dbHost, dbName, dbUser, dbPassword)
  6. Save a struct implementing EntityObject using Manager:

    p := Product{
      Title:       "Some product",
      Description: "A product for demo purposes",
    }
    
    viewID := 1
    saved, err := mgr.Create(p, viewID)
  7. Retrieve the struct based on it's ID and view ID:

    id := 1
    viewID := 1
    
    product := Product{}
    err := mgr.FindByID(id, viewID, &product)

About

Universal view and versioning

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •