You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

24 lines
456 B

const nome = _req.getString("nome");
const crm = _req.getString("crm");
var errors = _val.list();
if (!nome) {
errors.add("nome");
}
if (!crm) {
errors.add("crm");
}
if (nome && crm) {
var insertedData = _db.insertIfNotExists(
'medico',
_val.map()
.set("nome", nome)
.set("c_r_m", crm)
);
_out.json({insertedData: insertedData})
} else {
_out.json({erros: {"campos faltando": errors}})
}