I am facing an issue in printing the two statements, I have two functions
var mongoose = require( 'mongoose' );
var_show_test = mongoose.model( 'test' );
exports.showTest = function(req,res) {
var jsonString = [];
var_show_test.find(function (err, testa) {
console.log("In find");
});
console.log("In function");
}
but it is printing the statements in sequence
In function
In find
what i want is to print the statements in sequence e.g
In find
In function
I know it is happening due to asynchronous calling, I am little bit confused about callback functions. how to handle this in order to print the statements in sequence.