working updates

This commit is contained in:
erik-sn committed 2020-11-01 10:12:58 -05:00
1 parent 18be1a7d0f
commit ce951ceecc
10 files changed
+92 -53

No files matched your search

+8 -13
View File
@@ -4,6 +4,7 @@ import { pool } from './db';
import { useIdentifier } from './functions';
interface Note {
id?: number;
title: string;
content: string;
}
@@ -12,12 +13,6 @@ interface NoteId {
id: number
}
interface UpdateNote {
id: number;
title: string;
content: string;
}
async function addNote(identifier: string, note: Note): Promise<any> {
const query = "INSERT INTO npwd_notes (identifier, title, content) VALUES (?, ?, ?)"
await pool.query(query,
@@ -41,7 +36,7 @@ async function deleteNote(noteId: number, identifier: string) {
await pool.query(query, [noteId, identifier])
}
/*async function updateNote(note: UpdateNote, identifier: string): Promise<any> {
async function updateNote(note: Note, identifier: string): Promise<any> {
const query = "UPDATE npwd_notes SET title = ?, content = ? WHERE id = ? AND identifier = ?"
await pool.query(query, [
note.title,
@@ -49,7 +44,7 @@ async function deleteNote(noteId: number, identifier: string) {
note.id,
identifier
])
}*/
}
onNet(events.NOTE_ADD_NOTE, async (note: Note) => {
try {
@@ -84,13 +79,13 @@ onNet(events.NOTE_DELETE_NOTE, async (noteId: NoteId) => {
}
})
// coming soon tm
/*onNet(events.NOTE_UPDATE_NOTE, async (note: UpdateNote) => {
onNet(events.NOTE_UPDATE_NOTE, async (note: Note) => {
const _source = (global as any).source;
try {
const _identifier = await useIdentifier();
updateNote(note, _identifier)
emitNet(events.NOTE_UPDATE_NOTE_SUCCESS, _source)
} catch (error) {
console.log("NOTE ERROR:", error)
emitNet(events.NOTE_UPDATE_NOTE_FAILURE, _source)
}
})*/
})