code: func (n *HumanFriendlyNumber) BeforeCreate(scope *gorm.Scope) error {
  	upsertStmt := `
  		INSERT INTO number_sequences (space_id, table_name, current_val)
  		VALUES ($1, $2, 1)
  		ON CONFLICT (space_id, table_name)
  		DO UPDATE SET current_val = number_sequences.current_val + EXCLUDED.current_val
  		RETURNING current_val
  	`
  	var currentVal int
  	err := scope.NewDB().Debug().CommonDB().QueryRow(upsertStmt, n.spaceID, n.tableName).Scan(&currentVal)
  	if err != nil {
  		return errs.Wrapf(err, "failed to obtain next val for space %q and table %q", n.spaceID, n.tableName)
  	}
  	log.Debug(nil, map[string]interface{}{
  		"space_id":   n.spaceID,
  		"table_name": n.tableName,
  		"next_val":   currentVal,
  	}, "computed nextVal")
  
  	n.Number = currentVal
  	return scope.SetColumn("number", n.Number)
  }
docs: // BeforeCreate is a GORM callback (see http://doc.gorm.io/callbacks.html) that
  // will be called before creating the model. We use it to determine the next
  // human readable number for the model and set it automatically in the CREATE
  // query.