Reputation: 43
I know there are similar questions but they haven't help me.
I've got an error when trying to use .find() method on model: product2 (.query() method is working )
I was trying to find out how to get more verbose output from database, but with failure.
{
"error": "E_UNKNOWN",
"status": 500,
"summary": "Encountered an unexpected error",
"raw": {
"code": "ER_BAD_FIELD_ERROR",
"errno": 1054,
"sqlState": "42S22",
"index": 0
}
}%
my model "Product2.js"
module.exports = {
connection:'someMysqlServer',
migration:'safe',
tableName:'NUTR_DATA',
attributes:{
id:{
columnName:'Nutr_No',
primaryKey:true,
type:'string'
}
}
};
routes.js
module.exports.routes{
'GET /select':'Product2Controller.select'
};
Product2Controller.js
module.exports = {
select:function(req,res){
Product2.find({limit:10}).exec(function(err, results) {
if (err){res.serverError(err)}
else{res.json(results)};
});
}
};
database schema
+---------------+---------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+---------------+------+-----+---------+-------+
| NDB_No | varchar(5) | NO | PRI | NULL | |
| Nutr_No | varchar(3) | NO | PRI | NULL | |
| Nutr_Val | decimal(13,3) | NO | | NULL | |
| Num_Data_Ptr | decimal(10,0) | NO | | NULL | |
| Std_Error | decimal(11,3) | YES | | NULL | |
| Src_Cd | varchar(2) | NO | | NULL | |
| Deriv_cd | varchar(4) | YES | | NULL | |
| Ref_NDB_No | varchar(5) | YES | | NULL | |
| Add_Nutr_Mark | varchar(1) | YES | | NULL | |
| Num_Studies | int(11) | YES | | NULL | |
| Min | decimal(13,3) | YES | | NULL | |
| Max | decimal(13,3) | YES | | NULL | |
| DF | int(11) | YES | | NULL | |
| Low_EB | decimal(13,3) | YES | | NULL | |
| Up_EB | decimal(13,3) | YES | | NULL | |
| Stat_cmd | varchar(10) | YES | | NULL | |
| AddMod_Date | varchar(10) | YES | | NULL | |
| CC | varchar(1) | YES | | NULL | |
+---------------+---------------+------+-----+---------+-------+
Any ideas as to what is going wrong?
Upvotes: 1
Views: 582
Reputation: 43
Thank you for your responses. The problem was not setted
autoCreatedAt: false,
autoUpdatedAt: false
i hadn't see that my ide actually give me more verbose output then curl. Maybe it would be better if errors would be placed under calming picture of boat and info about lifted server :P
Upvotes: 2