So I want to save document with insert or update if exist, and figured out that findOneAndUpdate with opt {upsert:true} maybe could, but it encounter error when save(). How is proper use of this method? here is my code :
(node:21468) UnhandledPromiseRejectionWarning: TypeError: existdt.save is not a function
warning.js:18
at Function.Mdel.upsert (D:\app\botkorter\src\dbase.js:46:17)
So I want to save document with insert or update if exist, and figured out that
findOneAndUpdate
with opt{upsert:true}
maybe could, but it encounter error whensave()
. How is proper use of this method? here is my code :and this is the error msg: