My challenge lies in extracting data from MongoDB, but every time I attempt to use the find()
function, I encounter the following response. Being a novice in Mongo, I'm puzzled by why this issue is occurring. The code is written in TypeScript and is being utilized to develop a Discord bot.
Query {
_mongooseOptions: {},
_transforms: [],
_hooks: Kareem { _pres: Map(0) {}, _posts: Map(0) {} },
_executionStack: null,
mongooseCollection: Collection {
collection: null,
Promise: [Function: Promise],
modelName: 'verifiedUsers',
_closed: false,
opts: {
autoIndex: true,
autoCreate: true,
schemaUserProvidedOptions: {},
capped: false,
Promise: [Function: Promise],
'$wasForceClosed': undefined
},
name: 'verifiedUsers',
collectionName: 'verifiedUsers',
conn: NativeConnection {
base: [Mongoose],
collections: [Object],
models: [Object],
config: {},
replica: false,
options: null,
otherDbs: [],
relatedDbs: {},
states: [Object: null prototype],
_readyState: 0,
_closeCalled: false,
_hasOpened: false,
plugins: [],
id: 0,
_queue: [],
_listening: false
},
queue: [],
buffer: true,
emitter: EventEmitter {
_events: [Object: null prototype] {},
_eventsCount: 0,
_maxListeners: undefined,
[Symbol(kCapture)]: false
}
},
model: Model { verifiedUsers },
schema: Schema {
obj: { ign: [Object], memberid: [Object] },
paths: {
ign: [SchemaString],
memberid: [SchemaString],
_id: [ObjectId],
__v: [SchemaNumber]
},
aliases: {},
subpaths: {},
virtuals: { id: [VirtualType] },
singleNestedPaths: {},
nested: {},
inherits: {},
callQueue: [],
_indexes: [],
methods: {},
methodOptions: {},
statics: {},
tree: {
ign: [Object],
memberid: [Object],
_id: [Object],
__v: [Function: Number],
id: [VirtualType]
},
query: {},
childSchemas: [],
plugins: [ [Object], [Object], [Object], [Object], [Object] ],
'$id': 1,
mapPaths: [],
s: { hooks: [Kareem] },
_userProvidedOptions: {},
options: {
typeKey: 'type',
id: true,
_id: true,
validateBeforeSave: true,
read: null,
shardKey: null,
discriminatorKey: '__t',
autoIndex: null,
minimize: true,
optimisticConcurrency: false,
versionKey: '__v',
capped: false,
bufferCommands: true,
strictQuery: true,
strict: true,
pluralization: true
},
'$globalPluginsApplied': true
},
op: 'find',
options: {},
_conditions: {},
_fields: undefined,
_update: undefined,
_path: undefined,
_distinct: undefined,
_collection: NodeCollection {
collection: Collection {
collection: null,
The code snippet in use is as follows: Schema:
import mongoose from 'mongoose'
const verifiedUsers = new mongoose.Schema({
ign: {
type: String,
required: true
},
memberid: {
type: String,
required: true
},
})
export default mongoose.model('verifiedUsers', verifiedUsers, 'verifiedUsers')
get Verified Users:
import mongoose from 'mongoose'
import verifiedUsers from './schemas/verified-users'
client.on('ready', async () => {
await mongoose.connect(
process.env.mongo_uri || '',
{
keepAlive: true
})
})
async function getVerifiedUsers() {
console.log(verifiedUsers.find())
}
getVerifiedUsers()
What could be causing this issue and how can it be rectified?