Documentation ¶
Index ¶
- Constants
- Variables
- func Config(configData DatabaseStore)
- func CreateFile(name string) *os.File
- func DecodeJson[T IDecodedJson](r *http.Request) (*T, error)
- func Dump()
- func EncodeJson[T Row[string] | TableColumn | []Row[string]](obj T) (string, error)
- func ReadConfigFile[T []Table | []TableMetaData](name string) (T, error)
- func SyncDBFiles()
- func WriteFile(file io.Writer, binData any) error
- type ColumnIdType
- type DatabaseStore
- type DeleteRowType
- type File
- type FilterType
- type GetRow
- type IDecodedJson
- type NewColumn
- type NewRow
- type Row
- type RowIdType
- type Table
- type TableColumn
- type TableIdType
- type TableMetaData
- type UpdateRowData
Constants ¶
View Source
const DATA_FILE_NAME = ".store/data.bin"
View Source
const METADATA_FILE_PATH = ".store/metadata.bin"
Variables ¶
View Source
var ColumnsTypeEnum = [3]string{
"number",
"string",
"bool",
}
View Source
var ErrClosedFile error = errors.New("File is closed")
View Source
var ResponseStrings = map[string]string{
"T1": "Table with this id not found",
"C1": "This column type is not allowed",
"C2": "Column with this name was not found",
"R0": "Row with id %d has been found",
"R1": "Row with this id was not found",
"R2": "Row with id %d has been deleted",
"R3": "New row has been created with id %d",
}
Functions ¶
func Config ¶
func Config(configData DatabaseStore)
func CreateFile ¶
func DecodeJson ¶
func DecodeJson[T IDecodedJson](r *http.Request) (*T, error)
func EncodeJson ¶
func ReadConfigFile ¶
func ReadConfigFile[T []Table | []TableMetaData](name string) (T, error)
func SyncDBFiles ¶
func SyncDBFiles()
Types ¶
type ColumnIdType ¶
type ColumnIdType uint32
func FindColumnByName ¶
func FindColumnByName(tid TableIdType, name string) (ColumnIdType, error)
type DatabaseStore ¶
type DatabaseStore struct { Tables []Table TablesMetaData []TableMetaData }
var Store DatabaseStore
func Load ¶
func Load() (bool, DatabaseStore)
type DeleteRowType ¶
type DeleteRowType struct { Table TableIdType `json:"table"` // contains filtered or unexported fields }
type FilterType ¶
type GetRow ¶
type GetRow struct { Table TableIdType `json:"table"` // contains filtered or unexported fields }
type IDecodedJson ¶
type IDecodedJson interface { NewRow | GetRow | NewColumn | UpdateRowData | DeleteRowType }
type NewColumn ¶
type NewColumn struct { Name string `json:"name"` Table TableIdType `json:"table"` Type string `json:"type"` }
type NewRow ¶
type NewRow struct { Columns map[string]interface{} `json:"columns"` Table TableIdType `json:"table"` }
type Row ¶
type Row[T ColumnIdType | string] struct { Id RowIdType `json:"id"` Columns map[T]interface{} `json:"columns"` }
func GetRowById ¶
func GetRowById(tid TableIdType, id RowIdType) (Row[ColumnIdType], error)
type RowIdType ¶
type RowIdType uint64
func AddNewRow ¶
func AddNewRow(tid TableIdType, cols map[ColumnIdType]interface{}) (RowIdType, error)
type Table ¶
type Table struct { Id TableIdType Rows []Row[ColumnIdType] }
type TableColumn ¶
type TableColumn struct { Id ColumnIdType `json:"id"` Name string `json:"name"` Type uint8 `json:"type"` IsOptional bool `json:"isoptional"` }
type TableIdType ¶
type TableIdType uint8
type TableMetaData ¶
type TableMetaData struct { Name string Columns []TableColumn }
func (*TableMetaData) CreateNewColumn ¶
func (table *TableMetaData) CreateNewColumn(name string, colType uint8) (ColumnIdType, error)
type UpdateRowData ¶
type UpdateRowData struct { Table TableIdType `json:"table"` Colunms map[string]interface{} `json:"columns"` // contains filtered or unexported fields }
Click to show internal directories.
Click to hide internal directories.