-
If I want to query with mongoose/Redis directly inside export const getServerSideProps = (context) => {
// don't want to connect here!
const doc = await Model.findOne(....) // or mayby redis query
return {
props: {...}
}
} where should I connect to mongo/redis? I don't want to create connection every page. |
Beta Was this translation helpful? Give feedback.
Answered by
lfades
Jun 5, 2020
Replies: 1 comment
-
You can connect there but make sure that every time you try to connect, return a connection that was already created, you can see how here: examples/with-mongodb-mongoose/pages/index.js |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rafaelalmeidatk
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can connect there but make sure that every time you try to connect, return a connection that was already created, you can see how here: examples/with-mongodb-mongoose/pages/index.js