I have a code like this.
var loadSchema = function(className) {
var Schema = new schemaModel()
schemaModel.findOne({className: className}), (err, schema) => {
if (err) {
throw err
}
if (!schema) {
return 'schema not found'
}
var schemaOptions = schema.ob
return schemaOptions
})
}
Though I am returning result from a callback, the code is returning undefined data. In my thinking using callback we can initiate other works after the completion of one. I want to know how the callback work here.
Thanks.