Answer the question
In order to leave comments, you need to log in
Why does mongoose hang when creating an element?
console.log('searching');
let user = await UserModel.findOne(params);
console.log('search finished');
if (user == null) {
console.log('nothing');
user = await new UserModel(params).save(); // <== на этой строке зависает
console.log('created');
}
return user;
const data = await db().collection("users").insertOne(params);
Answer the question
In order to leave comments, you need to log in
I found the reason - it turns out I was stupid.
I had a pre-save method in the schema and forgot to call next on it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question