-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserGroupDao.js
More file actions
31 lines (23 loc) · 811 Bytes
/
UserGroupDao.js
File metadata and controls
31 lines (23 loc) · 811 Bytes
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
var UserGroup = require('./UserGroup.js');
function UserGroupDao() {
var pg = require('pg');
var conString = "postgres://valentina:030612ale@localhost:5432/prova";
this.client = new pg.Client(conString);
}
UserGroupDao.prototype.create = function (userGroup){
var self = this;
self.client.connect();
var query = self.client.query("INSERT INTO USER_GROUP (ID_USER,ID_GROUP) VALUES ("+userGroup.user+", "+ userGroup.group+")");
query.on('end', function() {
self.client.end();
});
};
UserGroupDao.prototype.destroy = function (userGroup){
var self = this;
self.client.connect();
var query = self.client.query("DELETE FROM USER_GROUP WHERE ID_USER = "+userGroup.user+" AND ID_GROUP = "+userGroup.group);
query.on('end', function() {
self.client.end();
});
}
module.exports = UserGroupDao;