infra

package
v0.4.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package infra defines dnote structure

Index

Constants

This section is empty.

Variables

View Source
var (
	// DnoteDirName is the name of the directory containing dnote files
	DnoteDirName = ".dnote"

	// SystemSchema is the key for schema in the system table
	SystemSchema = "schema"
)

Functions

func InitDB added in v0.4.5

func InitDB(ctx DnoteCtx) error

InitDB initializes the database. Ideally this process must be a part of migration sequence. But it is performed seaprately because it is a prerequisite for legacy migration.

func InitSystem added in v0.4.5

func InitSystem(ctx DnoteCtx) error

InitSystem inserts system data if missing

Types

type Book

type Book struct {
	Name  string `json:"name"`
	Notes []Note `json:"notes"`
}

Book holds a metadata and its notes

type Config

type Config struct {
	Editor string
	APIKey string
}

Config holds dnote configuration

type Dnote

type Dnote map[string]Book

Dnote holds the whole dnote data

type DnoteCtx

type DnoteCtx struct {
	HomeDir     string
	DnoteDir    string
	APIEndpoint string
	Version     string
	DB          *sql.DB
}

DnoteCtx is a context holding the information of the current runtime

func NewCtx added in v0.4.5

func NewCtx(apiEndpoint, versionTag string) (DnoteCtx, error)

NewCtx returns a new dnote context

type Note

type Note struct {
	UUID     string `json:"uuid"`
	Content  string `json:"content"`
	AddedOn  int64  `json:"added_on"`
	EditedOn int64  `json:"edited_on"`
	Public   bool   `json:"public"`
}

Note represents a single microlesson

type Timestamp

type Timestamp struct {
	LastUpgrade int64 `yaml:"last_upgrade"`
	// id of the most recent action synced from the server
	Bookmark int `yaml:"bookmark"`
	// timestamp of the most recent action performed by the cli
	LastAction int64 `yaml:"last_action"`
}

Timestamp holds time information

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL