func NewCustomerStore(db *badger.DB) *CustomerStore {
	st := badgerstore.NewStore(db).
		SetType(Customer{}).
		SetPrefix("customer")
	return &CustomerStore{
		Store: st,
		CustomersQuery: badgerstore.NewQueryStore(st, customersIndexQuery).
			AddIndex(idxCustomerName).
			AddIndex(idxCustomerCountryName),
	}
}
NewCustomerStore creates a new CustomerStore.
package main
import (
	"encoding/json"
	"io/ioutil"
	"net/url"
	"strconv"
	"strings"
	"github.com/dgraph-io/badger"
	"github.com/jirenius/go-res"
	"github.com/jirenius/go-res/store/badgerstore"
	"github.com/rs/xid"
)
type CustomerStore struct {
	*badgerstore.Store
	CustomersQuery *badgerstore.QueryStore
}
var (
	idxCustomerName = badgerstore.Index{
		Name: "idxCustomer_name",
		Key: func(v interface{}) []byte {
			customer := v.(Customer)
			return []byte(strings.ToLower(customer.Name))
		},
	}
	idxCustomerCountryName = badgerstore.Index{
		Name: "idxCustomer_country_name",
		Key: func(v interface{}) []byte {
			customer := v.(Customer)
			return []byte(customer.Country + "_" + strings.ToLower(customer.Name))
		},
	}
)