func (r Repository) Create(reader decode.DecoderReader) (interface{}, error) { cm := reader.Model().(Model) gsql := sql.Builder{}.Insert(climbTable, reader) stmt, err := r.Db.PrepareNamed(gsql) if err != nil { return cm, err } err = stmt.Get(&cm, cm) return cm, err }
func (r Repository) Update(reader decode.DecoderReader) (interface{}, error) { um := reader.Model().(Model) gsql := sql.Builder{}.Update(rockTable, reader) stmt, err := r.Db.PrepareNamed(gsql) if err != nil { return um, err } err = stmt.Get(&um, um) return um, err }
func columns(reader decode.DecoderReader) []string { var c []string for _, k := range reader.Fields() { field, ok := reflect.TypeOf(reader.Model()).FieldByName(k) if ok != true { fmt.Errorf("Field Not Found") } value := structTag(field) if value == "" { value = strings.ToLower(k) } c = append(c, value) } return c }