Developing a simple REST using Sails.js and Waterline-ORM, now facing Post.create is not a function problem while trying to create a simple object in orm on Post-request.
Model:
module.exports = {
attributes: {
title: {
type: "string",
required: true,
},
body: {
type: "string",
required: true,
},
},
};
Controller
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);
}
}
I've already checked documentation and official gh-issues, but there are no working advice, I don't understand what am I doing wron
As a first try, I would test using a different model name than
Post. Sails has some pre-defined stuff already in the global name-space and sometimes there are overlaps. In my own project, I had errors trying to name a modelFile. I wouldn't be surprised if the same were true forPost.Try renaming to something else and see if it fixes your issue.