package main

import (
	"fmt"
	"log"

	scribble "github.com/nanobox-io/golang-scribble"
)

type DB struct {
	Db *scribble.Driver
}

func InitDb(dbAddress string) *DB {
	var err error
	var db *DB

	db.Db, err = scribble.New("", nil)
	if err != nil {
		fmt.Println("Error", err)
	}

	log.Printf("App: %+v", db)

	return db
}

func (db *DB) Write(table string, key string, value interface{}) error {
	err := db.Db.Write(table, key, value)
	if err != nil {
		fmt.Println("Error", err)
		return err
	}
	return nil
}

func (db *DB) Read(table string, key string, value interface{}) error {
	err := db.Db.Read(table, key, value)
	if err != nil {
		fmt.Println("Error", err)
		return err
	}
	return nil
}
