query_set.go 429 字节
package dao

import pgTransaction "github.com/linmadan/egglib-go/transaction/pg"

func QuerySetCurrentSort(ptr *pgTransaction.TransactionContext, t string, parentId int) (int, error) {
	sql := "select max(sort) sort from metadata.query_sets where type =? and parent_id = ?"
	var result struct {
		Sort int
	}
	if _, err := ptr.PgTx.Query(&result, sql, t, parentId); err != nil {
		return 0, err
	}
	return result.Sort + 1, nil
}