Tried to get mongoose to work and once again, faced the curse of ORM. The problem I had with ORM is that, it is hard to debug because it doesn’t tell you where the problem is.
The task was simple: create an instance method such that the document can go to another document, fetching _id for another document, and fetch the final document. Extremely easy task yet I kept getting empty result.
Then I realized that the schema for one of the document was changed. Because the schema didn’t match the actual database, mongoose returned nothing. Will be more careful next time. But the fundamental problem is, how am I supposed to debug this, especially when a complex query involves many tables(collections).