I am getting following JSONObject from client.
{
"registerationId": 57502,
"firstName": "Taha",
"lastName": "Kirmani",
"dob": "10-08-1988",
"cnic": 4210137718361,
"gender": "Male"
}
This is how i am parsing it for now.
app.post('/addUser', function (req, res) {
var registrationId= req.body.registerationId;
var firstName= req.body.firstName;
var lastName= req.body.lastName;
var dob= req.body.dob;
//var randomQuery = connection.query('INSERT INTO students `COLUMN NAME` VALUES `VALUES NAME` //);
//
})
With the above approach i can put data in MySQL database, but i am looking for more efficient approach.
What i want to do is to pass the jsonObject to query, and it inserts the data in DB, so i won't be doing the req.body.id step for each route.
I am looking for something like this;
(insert into table (?) VALUES (?) , req.keys, req.values)