Converted the last pieces to new backend

Added created & updated time to blog
This commit is contained in:
Caleb Gardner
2024-08-02 05:05:56 -05:00
parent 40271fa088
commit fd89e568af
6 changed files with 41 additions and 68 deletions
+2 -2
View File
@@ -61,7 +61,7 @@ func (s *SWBackend) UploadProfile(w http.ResponseWriter, r *http.Request) {
Type: profType,
Profile: prof,
}
_, err = s.db.Collection("profiles").InsertOne(context.TODO(), toUpload)
_, err = s.db.Collection("profiles").InsertOne(context.Background(), toUpload)
if err != nil {
backend.ReturnError(w, http.StatusInternalServerError, "internal", "Server error")
log.Println("error inserting profile:", err)
@@ -72,7 +72,7 @@ func (s *SWBackend) UploadProfile(w http.ResponseWriter, r *http.Request) {
}
func (s *SWBackend) GetProfile(w http.ResponseWriter, r *http.Request) {
res := s.db.Collection("profiles").FindOne(context.TODO(), bson.M{"_id": r.PathValue("profileID")})
res := s.db.Collection("profiles").FindOne(context.Background(), bson.M{"_id": r.PathValue("profileID")})
if res.Err() == mongo.ErrNoDocuments {
backend.ReturnError(w, 404, "not found", "Profile not found")
return