func (d *ServiceDB) LoadService(serviceID string) (service types.Service, err error) {
	err = runTransaction(d.db, func(txn *sql.Tx) error {
		service, err = selectServiceTxn(txn, serviceID)
		return err
	})
	return
}
LoadService loads a service from the database.
Returns sql.ErrNoRows if the service isn't in the database.
package database
import (
	"database/sql"
	"encoding/json"
	"fmt"
	"time"
	"github.com/matrix-org/go-neb/api"
	"github.com/matrix-org/go-neb/types"
	"maunium.net/go/mautrix/id"
)
type ServiceDB struct {
	db      *sql.DB
	dialect string
}
var globalServiceDB Storer
func SetServiceDB(db Storer) {
	globalServiceDB = db
}
func GetServiceDB() Storer {
	return globalServiceDB
}
func Open(databaseType, databaseURL string) (serviceDB *ServiceDB, err error) {
	db, err := sql.Open(databaseType, databaseURL)
	if err != nil {
		return
	}
	if _, err = db.Exec(schemaSQL); err != nil {
		return
	}
	if databaseType == "sqlite3" {
		db.SetMaxOpenConns(1)
	}
	serviceDB = &ServiceDB{db: db, dialect: databaseType}
	return
}
func (d *ServiceDB) StoreMatrixClientConfig(config api.ClientConfig) (oldConfig api.ClientConfig, err error) {
	err = runTransaction(d.db, func(txn *sql.Tx) error {
		oldConfig, err = selectMatrixClientConfigTxn(txn, config.UserID)
		now := time.Now()
		if err == nil {
			return updateMatrixClientConfigTxn(txn, now, config)
		} else if err == sql.ErrNoRows {
			return insertMatrixClientConfigTxn(txn, now, config)
		} else {
			return err
		}
	})
	return
}
func (d *ServiceDB) LoadMatrixClientConfigs() (configs []api.ClientConfig, err error) {
	err = runTransaction(d.db, func(txn *sql.Tx) error {
		configs, err = selectMatrixClientConfigsTxn(txn)
		return err
	})
	return
}
func (d *ServiceDB) LoadMatrixClientConfig(userID id.UserID) (config api.ClientConfig, err error) {
	err = runTransaction(d.db, func(txn *sql.Tx) error {
		config, err = selectMatrixClientConfigTxn(txn, userID)
		return err
	})
	return
}
func (d *ServiceDB) UpdateNextBatch(userID id.UserID, nextBatch string) (err error) {
	err = runTransaction(d.db, func(txn *sql.Tx) error {
		return updateNextBatchTxn(txn, userID, nextBatch)
	})
	return
}
func (d *ServiceDB) LoadNextBatch(userID id.UserID) (nextBatch string, err error) {
	err = runTransaction(d.db, func(txn *sql.Tx) error {
		nextBatch, err = selectNextBatchTxn(txn, userID)
		return err
	})
	return
}