package sdb

type M map[string]any

func (m M) Int64(k string) int64 {
	v, ok := m[k].(int64)
	if !ok {
		return int64(m.Float64(k))
	}
	return v
}

func (m M) String(k string) string {
	v, ok := m[k].(string)
	if !ok {
		return ""
	}
	return v
}

func (m M) Any(k string) any {
	v, _ := m[k]
	return v
}

func (m M) Float64(k string) float64 {
	v, ok := m[k].(float64)
	if !ok {
		return 0
	}
	return v
}

func (m M) Bool(k string) bool {
	v, ok := m[k].(bool)
	if !ok {
		return false
	}
	return v
}

func (m M) Uint(k string) uint64 {
	v, ok := m[k].(uint64)
	if !ok {
		return uint64(m.Int64(k))
	}
	return v
}
