getClass()
и getInstance()
. Вы можете получить ссылку для класса Object с помощью window
.
function A() {
this.getClass = function() {
return window[this.constructor.name];
}
this.getNewInstance = function() {
return new window[this.constructor.name];
}
}
var a = new A();
console.log(a.getClass()); // function A { // etc... }
// you can even:
var b = new a.getClass();
b instanceof A; // true
function B() {};
B.getClass = function() {
return window[this.name];
}
B.getInstance() {
return new window[this.name];
}
В документации Mongoose говорится, что метод findOne () возвращает объект запроса. Итак, в следующей строке вы пытаетесь дождаться метода, который не возвращает обещание:
let memberofLobby = await UserLobby.findOne({username: user.username});
Я предлагаю добавить .exec () в конце строки, чтобы на самом деле выполнить findOne () и в результате получить обещание, как это.
let memberofLobby = await UserLobby.findOne({username: user.username}).exec();
Дайте мне знать, сработало ли это для вас!