From 971c21cdeef42a3ad585ab6b8c8c1b34f3264e9d Mon Sep 17 00:00:00 2001 From: Ayush Mukherjee Date: Thu, 16 Nov 2023 03:45:48 +0530 Subject: [PATCH] fix: change save behaviour for mongoose models --- src/ws/crud.js | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/src/ws/crud.js b/src/ws/crud.js index 8356509..aa7381d 100644 --- a/src/ws/crud.js +++ b/src/ws/crud.js @@ -22,10 +22,7 @@ const eventFns = { create: async (data) => { try { const ev = new events(data) - ev.save((err) => { - if (err) - console.warn(err) - }) + await ev.save(); } catch (e) { console.warn(e) } @@ -48,10 +45,7 @@ const rosterFns = { create: async (data) => { try { const ev = new rosters(data) - ev.save((err) => { - if (err) - console.warn(err) - }) + await ev.save(); } catch (e) { console.warn(e) } @@ -74,10 +68,7 @@ const matchFns = { create: async (data) => { try { const ev = new matches(data) - ev.save((err) => { - if (err) - console.warn(err) - }) + await ev.save(); } catch (e) { console.warn(e) } @@ -109,10 +100,7 @@ const streamFns = { create: async (data) => { try { const ev = new streams(data) - ev.save((err) => { - if (err) - console.warn(err) - }) + await ev.save(); } catch (e) { console.warn(e) } @@ -135,10 +123,7 @@ const casterFns = { create: async (data) => { try { const ev = new casters(data) - ev.save((err) => { - if (err) - console.warn(err) - }) + await ev.save(); } catch (e) { console.warn(e) } @@ -161,10 +146,7 @@ const hostFns = { create: async (data) => { try { const ev = new hosts(data) - ev.save((err) => { - if (err) - console.warn(err) - }) + await ev.save(); } catch (e) { console.warn(e) } @@ -196,10 +178,7 @@ const bracketFns = { create: async (data) => { try { const ev = new brackets(data) - ev.save((err) => { - if (err) - console.warn(err) - }) + await ev.save(); } catch (e) { console.warn(e) } @@ -214,4 +193,4 @@ module.exports = { 'casters': casterFns, 'hosts': hostFns, 'brackets': bracketFns, -} \ No newline at end of file +}