From 4b2e18caf18fef2141e731ffa34316cc7eb4ca3e Mon Sep 17 00:00:00 2001 From: sajjal Date: Wed, 3 Jul 2019 13:41:00 +0530 Subject: [PATCH] basic nserion created --- controllers/invoiceController.js | 7 +++++++ models/invoices.model.js | 3 +++ server.js | 5 ++++- views/invoices/addOrEdit.hbs | 8 ++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/controllers/invoiceController.js b/controllers/invoiceController.js index b35a2bc..346a234 100644 --- a/controllers/invoiceController.js +++ b/controllers/invoiceController.js @@ -8,4 +8,11 @@ router.get('/', (req,res)=> { }); }); +router.post('/',(req,res)=>{ + insertRecord(req,res); +} ); + +function insertRecord(req, res){ + +} module.exports = router; \ No newline at end of file diff --git a/models/invoices.model.js b/models/invoices.model.js index 56375a5..0c1f6a4 100644 --- a/models/invoices.model.js +++ b/models/invoices.model.js @@ -26,6 +26,9 @@ var invoiceSchema = new mongoose.Schema({ items_quantity: { type: Number }, + items_price:{ + tupe: Number + }, items_amount: { type: Number }, diff --git a/server.js b/server.js index 4e8b0b4..0ac4fd9 100644 --- a/server.js +++ b/server.js @@ -3,12 +3,15 @@ require('./models/db'); const express = require('express'); const path = require('path'); const exphbs =require('express-handlebars'); - +const bodyParser = require('body-parser'); const invoiceController = require('./controllers/invoiceController'); var app = express(); +app.use(bodyParser.urlencoded({extended:true})); +app.use(bodyParser.json()); + app.set('views', path.join(__dirname, '/views/')); app.engine('hbs', exphbs({extname:'hbs', defaultLayout: 'mainLayout', layoutsDir:__dirname+'/views/layouts/'})); app.set('view engine','hbs'); diff --git a/views/invoices/addOrEdit.hbs b/views/invoices/addOrEdit.hbs index 7ba4699..a246022 100644 --- a/views/invoices/addOrEdit.hbs +++ b/views/invoices/addOrEdit.hbs @@ -1,6 +1,6 @@

{{viewTitle}}

-
+
@@ -9,12 +9,12 @@
- +
- +
@@ -66,7 +66,7 @@
- +