rmxe-appl-template
v1.0.0
Published
This is application template that includes the following technologies: react, express, ts, mongodb, mobx, materialUI
Downloads
2
Readme
This is application template that includes the following technologies: react, express, ts, mongodb, mobx, materialUI
Setup MongoDB:
Install mongodb from official site https://www.mongodb.com/try/download/community
Run mongod.exe
Run mongo.exe test commands: use test db.users.insertOne( { name: "Tom" } ) db.users.find()
npm i mongodb 5 .Insert into server.js file folowing code:
const MongoClient = require("mongodb").MongoClient; const mongoClient = new MongoClient("mongodb://localhost:27017/");
interactions with the database:
async function run() { try { await mongoClient.connect(); const db = mongoClient.db("admin"); const result = await db.command({ping: 1}); console.log("connection established"); console.log('result', result) }catch(err) { console.log(err); } finally { await mongoClient.close(); console.log("connection closed"); } } run();