Y
Y
YakutD2018-05-22 18:09:19
MongoDB
YakutD, 2018-05-22 18:09:19

Why do I get undefined when trying to find out any information about an array?

Hello. I'm trying to find out from the database if there is a record with a certain field in the database or not.

var unique = collection.find({email: '[email protected]'}).toArray();
I want to say right away that there are a whole bunch of such records. If I want to output unique to the console, then I get all records with the given email. If I want to know the length of the array through unique.length ( https://docs.mongodb.com/manual/reference/method/c... , then it gives out undefined. Also, I get undefined if I want to display information about any of the array elements What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question