-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
knanahassouna1
committed
Oct 7, 2018
1 parent
0181960
commit b096eb2
Showing
2 changed files
with
55 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const db_connection = require('./../database/db_connection'); | ||
|
||
const addReservation = (object) => { | ||
const { | ||
user_id: userId, reservation_from: reservationFrom, reservation_to: reservationTo, room_id: roomId, | ||
} = object; | ||
const sql = { | ||
text: "insert into reservations (user_id,reservation_from,reservation_to,room_id,status) values ($1,$2,$3,$4,'underconfirm') returning * ;", | ||
values: [userId, reservationFrom, reservationTo, roomId], | ||
}; | ||
return new Promise((resolve, reject) => { | ||
db_connection.query(sql, (err, result) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(result.rows); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = { addReservation }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters