Skip to content

Instantly share code, notes, and snippets.

@alvinmespejo
Created March 3, 2018 01:51
Show Gist options
  • Save alvinmespejo/189b420799147b77575e774906462dbc to your computer and use it in GitHub Desktop.
Save alvinmespejo/189b420799147b77575e774906462dbc to your computer and use it in GitHub Desktop.
Realtor Preference
package preference
import (
"circlepix/pkg/database"
"strings"
)
func ReadByID(Id int64) (*Preference, error) {
p := Preference{}
err := database.Get(&p, "SELECT * FROM Preference WHERE PrefId = ?", Id)
if err != nil {
return nil, err
}
return &p, nil
}
func GetPreferences(prefType string, prefTypeId int64) ([]*Preference, error) {
p := []*Preference{}
prefType = strings.ToLower(prefType)
err := database.Get(&p, "SELECT * FROM Preference WHERE PREFtype = ? AND PREFtypeId = ? ", prefType, prefTypeId)
if err != nil {
return nil, err
}
return p, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment