Cannot read properties of undefined (reading 'Channel')

TypeError: Cannot read properties of undefined (reading 'Channel') at C:\Users\luizs\Documents\Discord Bot\Handlers\handleLogs.js:8:63 at C:\Users\luizs\Documents\Discord Bot\node_modules\mongoose\lib\model.js:5213:18 at process.processTicksAndRejections (node:internal/process/task_queues:77:11)
15 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Ashura
AshuraOP3y ago
İspik
İspik3y ago
data seems to be undefined sounds like mongodb issue Probably failed to match the query
Ashura
AshuraOP3y ago
got any ideia on how to correct this?
İspik
İspik3y ago
Well send me your mongodb schema model
Ashura
AshuraOP3y ago
const { model, Schema } = require("mongoose"); let logSchema = new Schema({ Guild: String, Channel: String, }); module.exports = model("Logs", logSchema);
İspik
İspik3y ago
Have you ever made a write to the database?
Ashura
AshuraOP3y ago
how can i do it
İspik
İspik3y ago
Well there's findOneAndUpdate method you should use it somewhere to put something inside database
Ashura
AshuraOP3y ago
İspik
İspik3y ago
Not exactly optimal but could work
Ashura
AshuraOP3y ago
same thing , still didnt work
İspik
İspik3y ago
Open your mongo atlas and see if there's anything inside it
Ashura
AshuraOP3y ago
nothing
İspik
İspik3y ago
So you're not inserting it correctly you might need to add .save() on the end of the .create() method

Did you find this page helpful?