Beispiel #1
13
func (pub *Publication) getProps(sess *dbr.Session, id string) ([]*pubProp, error) {
	var props []*pubProp
	_, err := sess.Select(
		"pubprop.value",
		"cvterm.name as term",
	).From("pubprop").
		Join("pub", dbr.Eq("pubprop.pub_id", "pub.pub_id")).
		Join("cvterm", dbr.Eq("pubprop.type_id", "cvterm.type_id")).
		Join("cv", dbr.Eq("cvterm.cv_id", "cv.cv_id")).
		Where(
			dbr.And(
				dbr.Eq("pub.uniquename", id),
				dbr.Eq("pub.is_obsolete", "0"),
				dbr.Eq("cv.name", "pub_type"),
			),
		).LoadStructs(&props)
	return props, err
}
Beispiel #2
0
func TransactionHandler(db *dbr.Session) echo.MiddlewareFunc {
	return func(next echo.HandlerFunc) echo.HandlerFunc {
		return echo.HandlerFunc(func(c echo.Context) error {
			tx, _ := db.Begin()

			c.Set(TxKey, tx)

			if err := next(c); err != nil {
				tx.Rollback()
				logrus.Debug("Transction Rollback: ", err)
				return err
			}

			logrus.Debug("Transction Commit")
			tx.Commit()

			return nil
		})
	}
}