vadimdemedes / mongorito

🍹 MongoDB ODM for Node.js apps based on Redux
1.38k stars 90 forks source link

Value is returning null after query #189

Open Texlo-Dev opened 7 years ago

Texlo-Dev commented 7 years ago

I am trying to query a document in the database like so:

const tag = await tags.findOne({
                    guildID: msg.guild.id,
                    tagName: collected.first().content,
                    tagInfo: {
                        author: msg.author.id
                    }
                })

msg.author.id is defined as 288855795951599617, msg.guild.id is defined as 321417443585032203 and collected.first().content is defined as "Test"

My document is

{
    "_id" : ObjectId("5968bbe5525fa71609bd5d57"),
    "guildID" : "321417443585032203",
    "tagName" : "Test",
    "tagContent" : "Test add",
    "tagInfo" : {
        "author" : "288855795951599617",
        "createdAt" : ISODate("2017-07-14T12:41:02.931Z")
    }
}

Whenever I query, it is null. Am I querying this wrong? I don't believe I am.

vadimdemedes commented 7 years ago

Check if guild.id and author.id are in fact strings, not ObjectIds.

Texlo-Dev commented 7 years ago

They are in fact strings. I attached .toString() just in case.

vadimdemedes commented 7 years ago

Could you create an isolated reproduction for this? Ideally, this is a separate git repository that I can clone and reproduce the bug. This would help tremendously in resolving this issue.