我真的很喜欢使用sequelize作为我的节点应用程序的ORM,但是现在,当你在查询时默认传递DAO对象时,我有点恼火.如何将raw选项始终设置为true?
我希望能够在调用Model.createSequelize 之后接收普通的原始对象,Sequelize是创建的对象本身,没有元数据或任何其他东西.就像{raw: true}选项一样Model.find.
我已经看到了这个答案:
将所有查询设置为raw = true sequelize,不,Model.create({name: 'test'}, {raw: true})不起作用.
谢谢
我试图获取用户在表单字段中输入的详细信息,以便我可以编辑和更新所选记录。但是,当我单击编辑按钮时,我在表单中看到空白表单字段。
router.get('/list', (req, res) => {
Employee.find((err, docs) => {
if (!err) {
res.render("employee/list", {
list: docs,
});
}
else {
console.log('Error in retrieving employee list :' + err);
}
});
})
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚出了什么问题。我已将用户输入的值传递为req.body。所有操作都正常工作,但无法更新记录,因为我无法从表单中获取用户 ID。
<tbody>
{{#each list}}
<tr>
<td>{{this.name}}</td>
<td>{{this.email}}</td>
<td>{{this.mobile}}</td>
<td>{{this.city}}</td>
<td>
<a href="/employee/{{this._id}}"><i class="fa fa-pencil fa-lg" aria-hidden="true"></i></a>
<a href="/employee/delete/{{this._id}}" onclick="return confirm('Are you sure to delete this record ?');"><i class="fa fa-trash fa-lg" aria-hidden="true"></i></a>
</td>
</tr>
{{/each}}
</tbody>
Run Code Online (Sandbox Code Playgroud)