Answer the question
In order to leave comments, you need to log in
Mongoose promises and async - await (and before that it just returned emptiness), but now why does the promise return?
async finduser(id) {
const us = await UserScheme.findOne({ id });
console.log('fck'); -- кстати это не отображает в консоли
return us;
}
checkAddUser(user) {
console.log('us .');
const ff = this.finduser(user.id);
const res = ff.length ? ff[0].id : undefined;
console.log('u3s .' + ff);
if (res === undefined) {
console.log(`${user.id} add new user`);
this.adduser(user.id, user.first_name, user.last_name, user.username);
return false;
}
if (ff[0].city != null) {
return ff;
}
console.log(`${user.id} authorized`);
return ff;
}
Answer the question
In order to leave comments, you need to log in
an async function returns a Promise, so you don't have a string in ff.
To get a row, you need to use await when calling this.finduser, for which you declare checkAddUser as async.
if anything, then I solved the problem, my Eslint + prettier ate an unused object during autosave. and this object initialized the connection to the database
True, xs, why the hell * didn’t write a single hint .....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question