Git Product home page Git Product logo

building-modern-app-with-nextjs-and-mongodb's Introduction

๐Ÿ‘‹ Hi, Iโ€™m Ado!

I am a full-stack software engineer, international speaker, and developer evangelist.

Professionally, I am a Lead Developer Advocate at MongoDB. Prior to that I led the Developer Evangelism team and Ambassador Program at Auth0. I am a Google Developer Expert for Web Technologies and spend most my time giving talks at conferences and meetups, mentoring and running workshops, and creating online content to help technology professionals.

I have over 15 years of software development experience working with technologies like Angular, NodeJS, Go, MongoDB, PostgreSQL, and many others. I have held many roles in my career ranging from engineering, research and development, and leadership in both startups and enterprises.

My passion has always been technology and education. I write tutorials, record video courses, and contribute to open source projects. I am an avid reader, occasional gamer, and tech gadget enthusiast.

If youโ€™d like to get in touch, you can find me on the social media networks above or email me directly at [email protected].

building-modern-app-with-nextjs-and-mongodb's People

Contributors

frinzekt avatar kukicado avatar nickavignone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

building-modern-app-with-nextjs-and-mongodb's Issues

Console is logging: "API resolved without sending a response for..."

Many thanks for putting this tutorial together @kukicado , this was very helpful to get me up and running with MongoDB and Next.js.

Your code is working for me, however each API call throws
API resolved without sending a response for /api/daily, this may result in a stalled requests. to the console similar to issue 10439.

I was wondering if you are able to replicate this issue and if you had a fix?

Dates

Great tutorial! Thanks so much for creating it.

Have one small question. I haven't been able to use findOne to get documents by date in the way you lay it out.

In daily.js your code is:

if(date){
    doc = await req.db.collection('daily').findOne({date: new Date(date)})
  } else {
    doc = await req.db.collection('daily').findOne()
  }

But because the dates in your data.json are formatted like "2020-01-22T08:00:00.000+00:00", the request does not work for me.

I ended up changing the date format to "2020-01-22T08:00:00.000Z" in the database and using the following code:

if(date){
    doc = await req.db.collection('daily').findOne({date: new Date(date).toJSON()})
  } else {
    doc = await req.db.collection('daily').findOne()
  }

But I am curious how it is supposed to work? And how you are supposed to request dates of your format?

Thanks!

maximum connections threshold

I've used this as a foundation for MongoDB connection, so far it works but I'm getting mails from MongoDB saying I've almost exhausted all my connections while i only have my website that access from Mongo and sometimes my local nodejs development server. What can be the cause?
my database.js

import nextConnect from 'next-connect';

const client = new MongoClient('mongodb+srv://username:[email protected]/?retryWrites=true&w=majority',
{
  useNewUrlParser: true,
  useUnifiedTopology: true,
});

async function database(req, res, next) {
  if (!client.isConnected()) await client.connect();
  req.dbClient = client;
  req.db = client.db('cercleSport');
  return next();
}

const middleware = nextConnect();

middleware.use(database);

export default middleware;```
------------------------------------------------------------+
------------------------------------------------------------+
One of my api endpoints 
pages/api/fetchallgames
//
```import nextConnect from 'next-connect';
import middleware from '@/middleware/database';

const handler = nextConnect();

handler.use(middleware);

handler.post(async (req, res) => {
    // Convert the object back to a JSON string;
    const league = req.body.league;
    const division = req.body.division;
    const fieldString = "${league}.${division}.games";
    let projectionObject = {_id: 0};
    projectionObject[fieldString] = 1;
    let doc = await req.db.collection('24').findOne({}, { projection: projectionObject });
    let games = doc[league][division].games;
    return res.status(200).json(games);
});

export default handler;```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.