store

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	Version int      `json:"version"`
	Entries []*Entry `json:"entries"`
}

DB represents an in-memory database of password records.

func FromJSON

func FromJSON(data []byte) (db *DB, err error)

FromJSON initializes a database instance from a serialized byte-slice.

func New

func New() (db *DB)

New initializes a new database instance.

func (*DB) Active

func (db *DB) Active() EntryList

Active returns a list containing all the database's active entries.

func (*DB) Add

func (db *DB) Add(entry *Entry)

Add inserts a new entry into the database.

func (*DB) All

func (db *DB) All() EntryList

All returns a list containing all the database's entries.

func (*DB) Import

func (db *DB) Import(data []byte) (int, error)

Import adds entries from a previously-exported byte-slice of JSON.

func (*DB) Inactive

func (db *DB) Inactive() EntryList

Inactive returns a list containing all the database's inactive entries.

func (*DB) PurgeInactive

func (db *DB) PurgeInactive()

Purge clears inactive entries from the database.

func (*DB) SetActive

func (db *DB) SetActive(id int)

SetActive sets an entry's active status to true.

func (*DB) SetInactive

func (db *DB) SetInactive(id int)

SetInactive sets an entry's active status to false.

func (*DB) Size

func (db *DB) Size() int

Size returns the number of active entries in the database.

func (*DB) TagMap

func (db *DB) TagMap() map[string]EntryList

TagMap returns a map of tags to entry-lists.

func (*DB) ToJSON

func (db *DB) ToJSON() (data []byte, err error)

ToJSON serializes a database instance as a byte-slice of JSON.

type Entry

type Entry struct {
	Id        int      `json:"id"`
	Active    bool     `json:"active"`
	Title     string   `json:"title"`
	Url       string   `json:"url"`
	Username  string   `json:"username"`
	Passwords []string `json:"passwords"`
	Email     string   `json:"email"`
	Tags      []string `json:"tags"`
	Notes     string   `json:"notes"`
}

An Entry object represents a single database record.

func NewEntry

func NewEntry() *Entry

NewEntry initializes a new Entry object.

func (*Entry) GetPassword

func (entry *Entry) GetPassword() string

GetPassword returns the newest password from the passwords list.

func (*Entry) SetPassword

func (entry *Entry) SetPassword(password string)

SetPassword appends a new password to the passsword list.

type EntryList

type EntryList []*Entry

An EntryList is a slice of Entry pointers.

func (EntryList) Contains

func (list EntryList) Contains(entry *Entry) bool

Contains returns true if the EntryList contains the specified entry.

func (EntryList) Export

func (list EntryList) Export() (string, error)

Export exports a list of entries as a JSON string.

func (EntryList) FilterActive

func (list EntryList) FilterActive() EntryList

FilterActive filters an EntryList returning only those entries which are active.

func (EntryList) FilterByAll

func (list EntryList) FilterByAll(queries ...string) EntryList

FilterByAll filters an EntryList returning entries which match *all* of the specified query strings, where each query string is a case-insensitive substring of the entry title. If a single query string is supplied it will first be checked to see if it matches a valid entry ID.

func (EntryList) FilterByAny

func (list EntryList) FilterByAny(queries ...string) EntryList

FilterByAny filters an EntryList returning entries which match *any* of the specified query strings. Each query string can be an entry ID or a case-insensitive substring of an entry title.

func (EntryList) FilterByIDString

func (list EntryList) FilterByIDString(queries ...string) EntryList

FilterByIDString filters an EntryList returning only those entries which match the specified query strings where each query string is an entry ID.

func (EntryList) FilterByTag

func (list EntryList) FilterByTag(tag string) EntryList

FilterByTag filters an EntryList returning only those entries which match the specified tag. Matches are case-insensitive.

func (EntryList) FilterInactive

func (list EntryList) FilterInactive() EntryList

FilterInactive filters an EntryList returning only those entries which are inactive.

type ExportEntry

type ExportEntry struct {
	Title     string   `json:"title"`
	Url       string   `json:"url"`
	Username  string   `json:"username"`
	Passwords []string `json:"passwords"`
	Email     string   `json:"email"`
	Tags      []string `json:"tags"`
	Notes     string   `json:"notes"`
}

An ExportEntry object represents a database record prepared for export.

Jump to

Keyboard shortcuts

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