How can I save the date and time in a table every time I connect to the database and find the number of times I connected?

Viewed 28
const express = require('express');
const mongoose = require('mongoose');
const bodyParser=require('body-parser');
const app = express();
var dbState = [ { value: 0, label: 'disconnected' },
                { value: 1, label: 'connected' },
                { value: 2, label: 'connecting' },
                { value: 3, label: 'disconnecting' }, ];
mongoose.connect('mongodb://localhost:27017/firstdatabase',{ useNewUrlParser: true },
      () => {conststate = Number(mongoose.connection.readyState);
console.log(dbState.find((f) => f.value == state).label, 'todb');});
0 Answers
Related