我有一个sequelize.js模型,其中包含以下属性
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
</head>
<body>
<form name="form">
<label for="bar">Enter Text</label>
<input id="bar" name="bar" type="text" value="" />
<input type="submit" id="submit" value="click" >
</form>
<!-- The result of the search will be rendered inside this div -->
<div id="result">Text Output: </div>
<script >
/* Get from elements values */
$("#submit").on("click", function(){
var values = $(this).serialize();
$.ajax({
url: "testajax.php",
type: "post",
async:true,
data: values ,
success: function (response) {
$('#result').html((response);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(textStatus, errorThrown);
}
});
});
</script>
</body>
</html>
当我查询模型时,结果中似乎省略了具有空值的属性。例如,如果我的评论为空,我会在结果中得到这个。
ratings: {
type: Sequelize.INTEGER,
required: true
},
comments: {
type: Sequelize.STRING,
required: false
}
我想要
{
ratings : 5
}
如果不在我的结果中手动插入{
ratings : 5,
comment : null
}
,我该如何实现这一目标?