-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
78 lines (69 loc) · 2.22 KB
/
app.js
File metadata and controls
78 lines (69 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//author: Ricardo J. Perez Torres
//description:
var MongoClient = require('mongodb').MongoClient;
const electron = require('electron');
const ipcRenderer = electron.ipcRenderer;
const $ = require('jquery');
//mongodb atlas cluster url
//url = "mongodb://zeroth:P455w0rd@ct-cluster-shard-00-00-y9kdv.mongodb.net:27017,ct-cluster-shard-00-01-y9kdv.mongodb.net:27017,ct-cluster-shard-00-02-y9kdv.mongodb.net:27017/test?ssl=true&replicaSet=CT-Cluster-shard-0&authSource=admin";
var url = "mongodb://mongodb-thezeroth.c9users.io:27017/test";
//Connect to mongodb atlas cluster
MongoClient.connect(url, (err, db)=>{
if(err) throw err;
console.log('DB connected');
// db.collection('costumers').drop((err, delOK)=>{
// if (err) throw err;
// if(delOK) console.log("deleted");
// });
// db.createCollection('costumers', (err, res)=>{
// if(err) throw err;
// console.log("Costumers Collection Created");
// });
$('#btnSend').click((e)=>{
e.preventDefault();
let data = {
firstname: $('#txtNombre').val(),
lastname: $('#txtApellido').val(),
user_id: $('#txtId').val(),
phone: $('#txtPhone').val()
}
db.collection('costumers').insertOne(data, (err, res)=>{
if(err) throw err;
console.log('Inserted.');
$('#costumer').trigger('reset');
console.log(res);
});
});
setInterval(()=>{
db.collection('costumers').find({}).toArray((err, result)=>{
console.log(result);
$('#content').empty();
result.forEach(function(element) {
$('#content').append("<h3>"+ element.firstname + " " + element.lastname + "</h3>");
}, this);
});
}, 5000);
});
$('#btnSearch').click((e)=>{
e.preventDefault();
ipcRenderer.send('btnSearchClick');
});
var app = new Vue({
el: '#app',
data: {
"links": [
{
"title": "Home",
"href": "#"
},
{
"title": "Menu",
"href": "#"
},
{
"title": "Movies",
"href": "#"
}
]
}
});