brillout/telefunc

Endless loading due to MongoDB ObjectID

kevincrossgrove opened this issue · 1 comments

Was getting an endless loading state in vike-react vike-react-query when using telefunc with MongoDB.

Here is an example

export default async function getEvent(eventCode: string) {
  const client = new MongoClient(process.env.MONGODB_CONNECTION_STRING || "");
  const db = client.db(process.env.MONGODB_DATABASE_NAME);

  const eventsDB = db.collection("Events");

  const event = await eventsDB.findOne<any>({
    Code: eventCode,
  });

  return event;
}

It can easily be fixed by converting the _id property from an objectID to a string, or delete the _id, filing because there was no error messages

Can you publish a reproduction? That'd be the best. I'll re-open then.