Waterline .create() is not a function
使用Sails.js和Waterline-ORM开发一个简单的REST,现在面对Post.create时,尝试在请求后的orm中创建一个简单的对象时,并不是一个函数问题。
型号:
1 2 3 4 5 6 7 8 9 10 11 12 | module.exports = { attributes: { title: { type:"string", required: true, }, body: { type:"string", required: true, }, }, }; |
控制器
1 2 3 4 5 6 7 8 9 | createPost: async (req, res) => { const title = req.body.title; const body = req.body.body; try { let newPost = Post.create({ title: title, body: body }).fetch(); } catch (error) { console.log(newPost); } } |
我已经检查过文档和正式的gh问题,但是没有工作建议,我不知道我在做什么wron
有时候,当编辑器自动加载一些其他Post文件而不是Sails全局模型时(例如控制器文件顶部的
作为第一次尝试,我将使用与
同样如此,我也不会感到惊讶。
尝试重命名为其他内容,看看是否可以解决您的问题。