mongorito icon indicating copy to clipboard operation
mongorito copied to clipboard

Value is returning null after query

Open Texlo-Dev opened this issue 7 years ago • 3 comments

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.

Texlo-Dev avatar Jul 14 '17 12:07 Texlo-Dev

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

vadimdemedes avatar Jul 14 '17 16:07 vadimdemedes

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

Texlo-Dev avatar Jul 14 '17 18:07 Texlo-Dev

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.

vadimdemedes avatar Jul 15 '17 15:07 vadimdemedes