I have defined a schema for add question and its like
var mongoose = require('mongoose');
var questionSchema = new mongoose.Schema({
question_set : String,
questions:[{
question_id : String,
question_no : Number
}]
});
I would like to insert variables say, ques_set = 'xyz' and an array question_array = [['id_1',1],['id_2',2],['id_3',3]].
I used this code to insert to mongodb
var questions = require('../schemas/questions');
exports.testing = function(req,res){
if (!req.body) return res.sendStatus(400)
var ques_set = 'xyz';
var question_array = [['id_1',1],['id_2',2],['id_3',3]];
var data = question({ques_set,question_array);
data.save(function(err) {
if (err) throw err;
else {
console.log('Question Inserted');
res.send("Question Inserted");
}
});
};
This shows me an error TypeError: object is not a function. Please help me, I just started nodejs. Thanks