package om

import (
	"golib/v2/features/sdb"
)

var (
	defaultDB *sdb.DB
)

func Open(name string) error {
	db, err := sdb.Open(name)
	if err != nil {
		return err
	}
	defaultDB = db
	return nil
}

func Table(name string) *ORM {
	if defaultDB == nil {
		panic("database unopened: need called om.Open() first")
	}
	return &ORM{TableName: name, DB: defaultDB}
}
