Skip to content

Commit

Permalink
fix: db insert not happening
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshs9 committed Nov 10, 2024
1 parent f114f68 commit 5d9cf2b
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { ProtoGrpcType } from "./generated/notes";
import type { NoteServiceHandlers } from "./generated/notes/NoteService";
import type { CreateNoteRequest } from "./generated/notes/CreateNoteRequest";
import type { CreateNoteResponse } from "./generated/notes/CreateNoteResponse";
import { Status } from "@grpc/grpc-js/build/src/constants";

const PROTO_FILE = "notes.proto";

Expand Down Expand Up @@ -42,18 +43,23 @@ const NoteService: NoteServiceHandlers = {
}

// I will not save audio, because too much work for an interview :/
const newNote = DB.getRepository(DBNote).create({
transcription: transcription,
});

callback(null, {
status: "success",
errorMessage: "",
note: {
transcription: newNote.transcription,
id: "" + newNote.id
},
});
DB.getRepository(DBNote).save({
transcription: transcription
}).then((newNote) => {
callback(null, {
status: "success",
errorMessage: "",
note: {
transcription: newNote.transcription,
id: "" + newNote.id
},
});
}).catch((err) => {
callback({
code: Status.INTERNAL,
details: err
})
})
},
// RPC Method to list all notes
ListNotes: (
Expand Down

0 comments on commit 5d9cf2b

Please sign in to comment.