мое обещание всегда отклоняется, даже если _name, которое я передаю в параметрах, не всегда совпадает с именем в коллекции, любая помощь будет высоко оценена Спасибо!
myCheckUser(_name) {
var self = this;
return new Promise((resolve, reject) => {
self.db.collection("USER").find({ "username": _name }, { $exists: true }).toArray(function (err, doc) //find if a value exists
{
console.log("DOC USERNAME: " + doc.username);
if (doc) //if it does
{
reject("Found user");
console.log(doc.username); // print out what it sends back
}
else // if it does not
{
console.log("Not in docs");
resolve("Not found continue logic!")
}
}
)
});
};