func (db *DB) Delete(ids ...string) (reserr error) {
	if len(ids) == 0 {
		return
	}
	reserr = db.db.Update(func(txn *badger.Txn) error {
		var viewList views = append([]View{db.sqView}, db.views...)
		for _, vid := range ids {
			if err := txn.Delete([]byte(keysp + vid)); err != nil {
				return err
			}
		}
		for _, vid := range ids {
			tx := newTransaction(txn)
			if _, err := viewList.buildAll(tx, vid, nil); err != nil {
				return err
			}
		}
		return nil
	})
	return
}
Delete a list of documents based on their ids.
All documents will be deleted from database in one write transaction.
package dockage
import (
	"bytes"
	"encoding/binary"
	"encoding/hex"
	"encoding/json"
	"strings"
	"github.com/dgraph-io/badger"
)
type DB struct {
	db     *badger.DB
	views  views
	sqView View
	sq     *badger.Sequence
}
func Open(opt Options) (resdb *DB, reserr error) {
	bopt := badger.DefaultOptions
	bopt.Dir = opt.Dir
	bopt.ValueDir = opt.ValueDir
	bdb, err := badger.Open(bopt)
	if err != nil {
		return nil, err
	}
	sq, err := bdb.GetSequence([]byte(pat4Sys(dbseq)), 512)
	if err != nil {
		reserr = err
		return
	}
	resdb = &DB{db: bdb, sq: sq}
	resdb.sqView = newView(viewdbseq,
		func(em Emitter, id string, doc interface{}) (inf interface{}, err error) {
			sq, err := resdb.sq.Next()
			if err != nil {
				return nil, err
			}
			if sq > 1000 && sq%1000 == 0 {
				go resdb.db.RunValueLogGC(0.5)
			}
			ix := make([]byte, 8)
			binary.BigEndian.PutUint64(ix, sq)
			ix = []byte(hex.EncodeToString(ix))
			em.Emit(ix, nil)
			return ix, nil
		})
	return
}
func (db *DB) Close() error {
	db.sq.Release()
	return db.db.Close()
}
func (db *DB) AddView(v View) { db.views = append(db.views, v) }
func (db *DB) DeleteView(v string) (reserr error) {
	name := string(fnvhash([]byte(v)))
	prefix := []byte(pat4View(name))
	reserr = db.db.Update(func(txn *badger.Txn) error {
		opt := badger.DefaultIteratorOptions
		opt.PrefetchValues = false
		itr := txn.NewIterator(opt)
		defer itr.Close()
		var todelete [][]byte
		for itr.Seek(prefix); itr.ValidForPrefix(prefix); itr.Next() {
			item := itr.Item()
			k := item.KeyCopy(nil)
			v, err := item.ValueCopy(nil)
			if err != nil {
				return err
			}
			if len(k) != 0 {
				todelete = append(todelete, k)
			}
			if len(v) != 0 {
				todelete = append(todelete, v)
			}
		}
		for _, vd := range todelete {
			if err := txn.Delete(vd); err != nil {
				return err
			}
		}
		return nil
	})
	return
}
func (db *DB) Put(docs ...interface{}) (reserr error) {
	if len(docs) == 0 {
		return
	}
	reserr = db.db.Update(func(txn *badger.Txn) error {
		var builds []idd
		for _, vdoc := range docs {
			id, frev, err := prepdoc(vdoc)
			if err != nil {
				return err
			}
			qres, _, qerr := db.queryView(Q{View: viewdbseq, Start: id, Prefix: id}, txn, true)
			if qerr != nil {
				return qerr
			}
			if frev == nil {
				if len(qres) > 0 {
					return ErrNoMatchRev
				}
			}
			if len(qres) > 0 && bytes.Compare(qres[0].Key, []byte(frev.Value().(string))) != 0 {
				return ErrNoMatchRev
			}
			em := newViewEmitter(newTransaction(txn), db.sqView)
			resinf, reserr := em.build(string(id), vdoc)
			if reserr != nil {
				return reserr
			}
			frev.Set(string(resinf.([]byte)))
			js, err := json.Marshal(vdoc)
			if err != nil {
				return err
			}
			if err := txn.Set(append([]byte(keysp), id...), js); err != nil {
				return err
			}
			builds = append(builds, idd{ID: string(id), Doc: vdoc})
		}
		for _, v := range builds {
			tx := newTransaction(txn)
			if _, err := db.views.buildAll(tx, v.ID, v.Doc); err != nil {
				return err
			}
		}
		return nil
	})
	return
}
func (db *DB) Get(docs interface{}, firstID string, restID ...string) (reserr error) {
	ids := append([]string{firstID}, restID...)
	reserr = db.db.View(func(txn *badger.Txn) error {
		var reslist []string
		for _, vid := range ids {
			vid := pat4Key(vid)
			item, err := txn.Get([]byte(vid))
			if err != nil {
				return err
			}
			v, err := item.ValueCopy(nil)
			if err != nil {
				return err
			}
			reslist = append(reslist, string(v))
		}
		js := "[" + strings.Join(reslist, ",") + "]"
		return json.Unmarshal([]byte(js), docs)
	})
	return
}