Tuesday, January 24, 2023

Koneksi Databasse MongoDB Pada Node.js

 


1. Create Connection

1.1. Download MongoDB : apt-get install mongodb


1.2. Install MongoDB :  npm install mongodb --save


1.3. start MongoDb services : service mongodb start 


2. Create Database

var MongoClient = require('mongodb').MongoClient;  

var url = "mongodb://localhost:27017/MongoDb";  

MongoClient.connect(url, function(err, db) {  

if (err) throw err;  

console.log("Database created!");  

db.close();  

});


3. Create Collection

var MongoClient = require('mongodb').MongoClient;  

var url = "mongodb://localhost:27017/ MongoDb";  

MongoClient.connect(url, function(err, db) {  

if (err) throw err;  

db.createCollection("employees", function(err, res) {  

if (err) throw err;  

console.log("Collection is created!");  

db.close();  

});  

});



Memunculkan Simbol & Emoji Pada OS Mac

  Memunculkan Simbol & Emoji  1. Buka aplikasi Pages / Notes pada Macbook. 2. Klik pada Menubar Edit --> Pilih Emoji and Symbols a...