{"modulePath":"github.com/dNote/dnote","version":"v0.6.2","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package core\n\n## Variables\n\n```go\nvar (\n\t// ConfigFilename is the name of the config file\n\tConfigFilename = \"dnoterc\"\n\t// TmpContentFilename is the name of the temporary file that holds editor input\n\tTmpContentFilename = \"DNOTE_TMPCONTENT\"\n)\n```\n\n## Functions\n\n```go\nfunc CheckUpdate(ctx infra.DnoteCtx) error\n```\nCheckUpdate triggers update if needed\n\n```go\nfunc DeleteSystem(db *infra.DB, key string) error\n```\nDeleteSystem delets the given system record\n\n```go\nfunc GetBookUUID(ctx infra.DnoteCtx, label string) (string, error)\n```\nGetBookUUID returns a uuid of a book given a label\n\n```go\nfunc GetCipherKey(ctx infra.DnoteCtx) ([]byte, error)\n```\nGetCipherKey retrieves the cipher key and decode the base64 into bytes.\n\n```go\nfunc GetConfigPath(ctx infra.DnoteCtx) string\n```\nGetConfigPath returns the path to the dnote config file\n\n```go\nfunc GetDnoteTmpContentPath(ctx infra.DnoteCtx) string\n```\nGetDnoteTmpContentPath returns the path to the temporary file containing content being added or edited\n\n```go\nfunc GetEditorInput(ctx infra.DnoteCtx, fpath string, content *string) error\n```\nGetEditorInput gets the user input by launching a text editor and waiting for it to exit\n\n```go\nfunc GetSystem(db *infra.DB, key string, dest interface{}) error\n```\nGetSystem scans the given system configuration record onto the destination\n\n```go\nfunc GetValidSession(ctx infra.DnoteCtx) (string, bool, error)\n```\nGetValidSession returns a session key from the local storage if one exists and is not expired If one does not exist or is expired, it prints out an instruction and returns false\n\n```go\nfunc InitFiles(ctx infra.DnoteCtx) error\n```\nInitFiles creates, if necessary, the dnote directory and files inside\n\n```go\nfunc InitSystem(ctx infra.DnoteCtx) error\n```\nInitSystem inserts system data if missing\n\n```go\nfunc InsertSystem(db *infra.DB, key, val string) error\n```\nInsertSystem inserets a system configuration\n\n```go\nfunc LogAction(tx *sql.Tx, schema int, actionType, data string, timestamp int64) error\n```\nLogAction logs action and updates the last\\_action\n\n```go\nfunc ReadConfig(ctx infra.DnoteCtx) (infra.Config, error)\n```\nReadConfig reads the config file\n\n```go\nfunc SanitizeContent(s string) string\n```\nSanitizeContent sanitizes note content\n\n```go\nfunc UpdateSystem(db *infra.DB, key, val interface{}) error\n```\nUpdateSystem updates a system configuration\n\n```go\nfunc UpsertSystem(db *infra.DB, key, val string) error\n```\nUpsertSystem inserts or updates a system configuration\n\n```go\nfunc WriteConfig(ctx infra.DnoteCtx, config infra.Config) error\n```\nWriteConfig writes the config to the config file\n\n## Types\n\n```go\ntype Book struct {\n\tUUID    string `json:\"uuid\"`\n\tLabel   string `json:\"label\"`\n\tUSN     int    `json:\"usn\"`\n\tNotes   []Note `json:\"notes\"`\n\tDeleted bool   `json:\"deleted\"`\n\tDirty   bool   `json:\"dirty\"`\n}\n```\nBook holds a metadata and its notes\n\n```go\nfunc NewBook(uuid, label string, usn int, deleted, dirty bool) Book\n```\nNewBook constructs a book with the given data\n\n```go\nfunc (b Book) Expunge(db *infra.DB) error\n```\nExpunge hard-deletes the book from the database\n\n```go\nfunc (b Book) Insert(db *infra.DB) error\n```\nInsert inserts a new book\n\n```go\nfunc (b Book) Update(db *infra.DB) error\n```\nUpdate updates the book with the given data\n\n```go\nfunc (b *Book) UpdateUUID(db *infra.DB, newUUID string) error\n```\nUpdateUUID updates the uuid of a book\n\n```go\ntype Note struct {\n\tUUID     string `json:\"uuid\"`\n\tBookUUID string `json:\"book_uuid\"`\n\tBody     string `json:\"content\"`\n\tAddedOn  int64  `json:\"added_on\"`\n\tEditedOn int64  `json:\"edited_on\"`\n\tUSN      int    `json:\"usn\"`\n\tPublic   bool   `json:\"public\"`\n\tDeleted  bool   `json:\"deleted\"`\n\tDirty    bool   `json:\"dirty\"`\n}\n```\nNote represents a note\n\n```go\nfunc NewNote(uuid, bookUUID, body string, addedOn, editedOn int64, usn int, public, deleted, dirty bool) Note\n```\nNewNote constructs a note with the given data\n\n```go\nfunc (n Note) Expunge(db *infra.DB) error\n```\nExpunge hard-deletes the note from the database\n\n```go\nfunc (n Note) Insert(db *infra.DB) error\n```\nInsert inserts a new note\n\n```go\nfunc (n Note) Update(db *infra.DB) error\n```\nUpdate updates the note with the given data\n\n```go\nfunc (n *Note) UpdateUUID(db *infra.DB, newUUID string) error\n```\nUpdateUUID updates the uuid of a book\n\n```go\ntype RunEFunc func(*cobra.Command, []string) error\n```\nRunEFunc is a function type of dnote commands\n\n","path":"github.com/dNote/dnote/core","name":"core","synopsis":"","isRedistributable":true}
