mikorm

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: GPL-3.0 Imports: 8 Imported by: 0

README

Logo

Mikrotik ORM (mikorm)

Library Mikrotik API menggunakan ORM untuk mempermudah integrasi ke Mikrotik

Acknowledgements

Badges

MIT License GPLv3 License AGPL License

Authors

Installation

Install mikorm with go get

go get github.com/didintri196/mikorm@v1.0.0

Usage/Examples

package main

import (
	"fmt"
	"github.com/didintri196/mikorm"
)

func main() {
	config := mikorm.Configs{
		Ip:        "127.0.0.1",
		Port:      "8728",
		Username:  "admin",
		Password:  "",
		ModeDebug: true,
	}
	connRouteOS := mikorm.New(config)

......

}

Documentation

Documentation

Features


type SecretRepository struct {
    MikORM *mikorm.MikORM
}

func (repo SecretRepository) Browse(filter models.Secret) (secrets []models.Secret, err error) {
    err = repo.MikORM.Command("/ppp/secret").Where(&filter).Scan(&secrets).Error
    return
}

func (repo SecretRepository) Add(secret models.Secret) (err error) {
    return repo.MikORM.Command("/ppp/secret").Add(&secret).Error
}

func (repo SecretRepository) Read(filter models.Secret) (secret models.Secret, err error) {
    err = repo.MikORM.Command("/ppp/secret").Where(&filter).Print(&secret).Error
    return
}

func (repo SecretRepository) Edit(filter models.Secret, data models.Secret) (err error) {
    err = repo.MikORM.Command("/ppp/secret").SetByID("", &data).Error
    return
}

func (repo SecretRepository) Remove(ID string) (err error) {
    err = repo.MikORM.Command("/ppp/secret").RemoveByID(ID).Error
    return
}

func (repo SecretRepository) Enable(ID string) (err error) {
    err = repo.MikORM.Command("/ppp/secret").EnableByID(ID).Error
    return
}

func (repo SecretRepository) Disable(ID string) (err error) {
    err = repo.MikORM.Command("/ppp/secret").DisableByID(ID).Error
    return
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterLog

func RegisterLog() zerolog.Logger

Types

type Configs

type Configs struct {
	Ip        string
	Port      string
	Username  string
	Password  string
	ModeDebug bool
	UseTls    bool
}

type MikORM

type MikORM struct {
	Configs
	*routeros.Reply
	Error error
	zerolog.Logger
	Query  []string
	Filter []string
}

func New

func New(config Configs) MikORM

func (*MikORM) Add

func (route *MikORM) Add(data interface{}) *MikORM

func (*MikORM) Command

func (route *MikORM) Command(query string) *MikORM

func (*MikORM) DetectError

func (route *MikORM) DetectError() bool

func (*MikORM) DisableByID

func (route *MikORM) DisableByID(ID string) *MikORM

func (*MikORM) EnableByID

func (route *MikORM) EnableByID(ID string) *MikORM

func (*MikORM) Print

func (route *MikORM) Print(bind interface{}) *MikORM

func (*MikORM) RemoveByID

func (route *MikORM) RemoveByID(ID string) *MikORM

func (*MikORM) Run

func (route *MikORM) Run(query []string) *MikORM

func (*MikORM) Scan

func (route *MikORM) Scan(bind interface{}) *MikORM

func (*MikORM) SetByID

func (route *MikORM) SetByID(ID string, data interface{}) *MikORM

func (*MikORM) Where

func (route *MikORM) Where(filter interface{}) *MikORM

Jump to

Keyboard shortcuts

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