| 888 | } |
| 889 | |
| 890 | func (db *datastore) GetCollectionForPad(alias string) (*Collection, error) { |
| 891 | c := &Collection{Alias: alias} |
| 892 | |
| 893 | row := db.QueryRow("SELECT id, alias, title, description, privacy FROM collections WHERE alias = ?", alias) |
| 894 | |
| 895 | err := row.Scan(&c.ID, &c.Alias, &c.Title, &c.Description, &c.Visibility) |
| 896 | switch { |
| 897 | case err == sql.ErrNoRows: |
| 898 | return c, impart.HTTPError{http.StatusNotFound, "Collection doesn't exist."} |
| 899 | case err != nil: |
| 900 | log.Error("Failed selecting from collections: %v", err) |
| 901 | return c, ErrInternalGeneral |
| 902 | } |
| 903 | c.Public = c.IsPublic() |
| 904 | |
| 905 | return c, nil |
| 906 | } |
| 907 | |
| 908 | func (db *datastore) GetCollectionByID(id int64) (*Collection, error) { |
| 909 | return db.GetCollectionBy("id = ?", id) |