skip to Main Content

How to connect mongoDB in react

Such a problem that when I try to simply connect mongoDB in react import React, {Component} from 'react'; export default class App extends Component{ componentDidMount(){ const {MongoClient} = require('mongodb'); const client = new MongoClient('mongodb+srv://dafu4k:****@cluster0.jd26aac.mongodb.net/?retryWrites=true&w=majority'); const start = async () =>…

VIEW QUESTION

Mongodb – Count posts of user with default value

Supposed I have a data of [ { "_id": "629eb5ced774223d36a68907", "userId": "629eb22698df1015e980a98f", "posts": [ { "_id": "629eb59ad774223d36a688fa", "title": "titletestz", "body": "bodyz", "createdAt": "2022-06-07T02:19:06.314Z", "updatedAt": "2022-06-07T02:19:06.314Z", "__v": 0 }, { "_id": "629eb59ad774223d36a688fc", "title": "titletestx", "body": "bodyx", "createdAt": "2022-06-07T02:19:06.879Z", "updatedAt": "2022-06-07T02:19:06.879Z", "__v":…

VIEW QUESTION
Back To Top
Search