Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var MongoClient = require('mongodb').MongoClient;
- var url = "not going to leak my mongo details";
- document.ready(function(){
- MongoClient.connect(url, function(err, db) {
- if (err) throw err;
- db.createCollection("Logins", function(err, res) {
- if (err) throw err;
- console.log("Table created!");
- db.close();
- });
- });
- function submitData(){
- var usnfield = document.getElementById("usn").value;
- var pwdfield = document.getElementById("pwd").value;
- document.getElementById('submit').click(function(){
- MongoClient.connect(url, function(err, db) {
- if (err) throw err;
- var myobj = { Username: usnfield, Password: pwdfield };
- db.collection("Logins").insertOne(myobj, function(err, res) {
- if (err) throw err;
- console.log("1 record inserted");
- db.close();
- });
- });
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement