Currently in the process of building a basic REST API using Sails.js and Waterline-ORM, I've encountered an issue regarding Post.create is not a function when trying to create an object within the ORM on a Post request.
Here is my model:
module.exports = {
attributes: {
title: {
type: "string",
required: true,
},
body: {
type: "string",
required: true,
},
},
};
And here is the controller code:
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 have already consulted the documentation and official GitHub issues, but none of the solutions provided seem to be working. I am struggling to identify where the mistake lies.