linked customer id with bores

master
varun 3 years ago
parent 85527b20f5
commit 51a67ef69b

@ -125,7 +125,6 @@ exports.tankerBooking = async (req, reply) => {
address: req.body.address,
dateOfOrder: req.body.dateOfOrder,
};
var tankersBookingData = new Tankerbooking(bookingsData);
@ -175,9 +174,9 @@ exports.addBores = async (req, reply) => {
try {
//const username = req.params.username;
var customerId = req.params.customerId;
//console.log(req.params);
const username = loginObject.user.username;
//const username = loginObject.user.username;
//console.log(loginObject.user.username)
// const userInfo = await User.findOne({ username: username.toString() });
// const updateData = req.body;
@ -193,7 +192,7 @@ exports.addBores = async (req, reply) => {
var bore_Name = req.body.boreName
var i_bore = await Bore.findOne({ boreName: bore_Name})
var i_bore = await Bore.findOne({ boreName: bore_Name,customerId:customerId})
if(i_bore){
throw new Error('Bore already exists');
}
@ -205,6 +204,7 @@ exports.addBores = async (req, reply) => {
if (checkFormEncoding.isUserFormUrlEncoded) {
usertobeInserted = checkFormEncoding.bores;
console.log("thsi true url string");
tank.customerId = usertobeInserted.customerId
bores.boreName = usertobeInserted.boreName;
bores.typeofwater = usertobeInserted.typeofwater;
bores.description = usertobeInserted.description;

@ -111,6 +111,6 @@ exports.getTank = async (req, reply) => {
reply.send({ error: err });
});
} catch (err) {
throw boom.boomify
throw boom.boomify(err);
}
};

@ -240,7 +240,6 @@ exports.addUser = async (req, reply) => {
inchargeName: insertedUser.inchargeName,
buildingName: insertedUser.buildingName,
emails: [
{
email: insertedUser.emails[0].email,

@ -45,6 +45,7 @@ const userSchema = new mongoose.Schema(
oneTimePasswordSetFlag: { type: Boolean, default: false },
emails: [{ email: String, verified: { type: Boolean, default: false } }],
services: { password: { bcrypt: String } },
profile: {
role: [{ type: String, default: "user" }],
firstName: { type: String, default: null },

@ -11,7 +11,7 @@ const RoleSchema = new Schema({ name: String });
const tankersSchema = new mongoose.Schema({
customerId: { type: String, default: null },
tankerName: { type: String, default: null },
phoneNumber: { type: String, default: null },
typeofwater: [{ type: String, default: null }],
@ -20,7 +20,7 @@ const tankersSchema = new mongoose.Schema({
});
const tankersbookingSchema = new mongoose.Schema({
customerId: { type: String, default: null },
bookingid: { type: String, default: null,unique: true },
dateOfOrder: { type: String, default: null },
typeofwater: { type: String, default: null },
@ -37,7 +37,7 @@ const tankersbookingSchema = new mongoose.Schema({
});
const boreSchema = new mongoose.Schema({
customerId: { type: String, default: null },
boreName: { type: String, default: null },
typeofwater: { type: String, default: null },
description: { type: String, default: null },
@ -45,6 +45,7 @@ const boreSchema = new mongoose.Schema({
});
const Tanker = mongoose.model("Tanker", tankersSchema);
const Tankerbooking = mongoose.model("Tankerbooking", tankersbookingSchema);
const Bore = mongoose.model("Bore", boreSchema);

Loading…
Cancel
Save