And about your P.S.: I got the function working and simplified it to this:
export const deleteDocumentWithId = async (id: string) => {
await mongoose.connect(dbUrl);
await OrderModel.findByIdAndDelete(id);
await mongoose.disconnect();
};
Does this resemble how you normally use it?