I found this article here:
Looking at the last example connecting with Static Geeration with MongoDB
Could anybody provide a sample code for the
import { connectToDatabase } from “…/util/mongodb”;
^^^ the …util/mongodb code is not shown in the article.
From there I can go to the rest of it like this and start working with the data.
export async function getStaticProps() {
10 const { db } = await connectToDatabase();
11
12 const movies = await db
13 .collection(“movies”)
14 .find({})
15 .sort({ metacritic: -1 })
16 .limit(1000)
17 .toArray();
18
19 return {
20 props: {
21 movies: JSON.parse(JSON.stringify(movies)),
22 },
23 };
24 }