Document System Tutorial Part 2 - Creating and Registering a Model (Current Progress)

Back to Previous Page

Structure:

models

folder.go

Back to Top

package models

import (
    "github.com/uadmin/uadmin"
)

// Folder !
type Folder struct {
    uadmin.Model
    Name     string
    Parent   *Folder
    ParentID uint
}

main.go

Back to Top

package main

import (
    // Specify the username that you used inside github.com folder
    "github.com/username/document_system/models"
    "github.com/uadmin/uadmin"
)

func main() {
    // Register models to uAdmin
    uadmin.Register(
        models.Folder{},
    )

    // Assign Site Name value as "Document System"
    // NOTE: This code works only if database does not exist yet.
    uadmin.SiteName = "Document System"

    // Activates a uAdmin server
    uadmin.StartServer()
}

uadmin.db

Folders

Back to Top

../../../_images/foldermodelupdate.png