Skip to content

Instantly share code, notes, and snippets.

@LandimTiago
Created April 14, 2020 18:44
Show Gist options
  • Save LandimTiago/9d5200340758a7c238d22997f090a982 to your computer and use it in GitHub Desktop.
Save LandimTiago/9d5200340758a7c238d22997f090a982 to your computer and use it in GitHub Desktop.
edit(req, res) {
member.find(req.params.id, function (member) {
if (!member) return res.send("Intructor not found!")
member.birth = date(member.birth).iso
member.instructorsSelectOptions(function (options) {
return res.render("members/edit", { members, instructorOptions: options })
})
})
},
instructorsSelectOptions(callback) {
db.query(
`SELECT name, id
FROM instructors`,
function(err, results) {
if (err) throw `Database error! ${err}`
callback(results.rows)
})
}
D:\Codigos\DB-gym\src\app\controllers\members.js:42
member.instructorsSelectOptions(function (options) {
^
TypeError: member.instructorsSelectOptions is not a function
at D:\Codigos\DB-gym\src\app\controllers\members.js:42:20
at D:\Codigos\DB-gym\src\app\models\member.js:50:13
at Query.<anonymous> (D:\Codigos\DB-gym\node_modules\pg-pool\index.js:371:18)
at Query.handleReadyForQuery (D:\Codigos\DB-gym\node_modules\pg\lib\query.js:121:12)
at Connection.<anonymous> (D:\Codigos\DB-gym\node_modules\pg\lib\client.js:256:19)
at Connection.emit (events.js:310:20)
at Socket.<anonymous> (D:\Codigos\DB-gym\node_modules\pg\lib\connection.js:120:12)
at Socket.emit (events.js:310:20)
at addChunk (_stream_readable.js:286:12)
at readableAddChunk (_stream_readable.js:268:9)
[nodemon] app crashed - waiting for file changes before starting...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment