On Deploy I get Type error: This expression is not callable for MongoDB Model.find({}) call

This is the code, and it works as expected in dev environment. In fact, I know that this same code has deployed successfully in the past. But I’m absolutely stuck on this, with no idea what to try.

  try {
    await connectToMongoDB();
    const techColors = await TechColor.find({}).exec();
    return res.status(200).json({ success: true, techColors });
  } catch (error) {
    return res.status(500).json({
      success: false,
      message: "Error getting EmployeeColor[]",
      error,
    });
  }

The error seems to be compaining about the TechColor.find({}) call.
I’m using mongoose.
UPDATE - AS I WAS TYPING LAST SENTENCE IT OCURRED TO ME TO UPDATE THE MONGOOSE MODULE. NOW EVERYTHING IS FINE. HOW NICE FOR ME!

This is the error displayed in Vercel when I try to deploy

Type error: This expression is not callable.

19:25:34.892 Each member of the union type '{ <ResultDoc = any>(filter: FilterQuery<any>, projection: ProjectionType<any>, options: QueryOptions<any> & { lean: true; }): Query<(FlattenMaps<any> & Required<...>)[], ... 4 more ..., {}>; <ResultDoc = any>(filter: FilterQuery<...>, projection?: ProjectionType<...>, options?: QueryOptions<...>): Query<...>; <Resul...' has signatures, but none of those signatures are compatible with each other.

Hi, @minyenyimyinyen!

As I can see from your post:

It looks like you got the solution :raised_hands: Thanks for sharing!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.