'Mongoose: `findOne()` returns undefined
I am trying to find a single document from my mongoDB database but it's always returning undefined, but the that document exists in the collection
User.findOne({ discordId: (message.author.id) }, (err, data) => {
console.log(data) // returns `undefined`
})
The User model
const mongoose = require('mongoose')
const UserSchema = new mongoose.Schema({
discordId: {
type: mongoose.Schema.Types.Decimal128,
required: true,
unique: true
},
playing: {
type: Boolean
},
response: {
type: String
},
points: {
type: Number
}
})
module.exports = mongoose.model('User', UserSchema, 'User')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
