Attempting to post a string from client to mongoDB in Sails
val is a string posted in real time from the client to the server database
POST Form( is html the right choice here? )
<!DOCTYPE html>
<html>
<body>
<form action="post" method="post">
<p>
<label for="val">'Enter val'</label>
<input type="text" name="val" autofocus />
<input type="submit" />
</p>
</form>
</body>
`
routes.js (?)
'/post': {controller: "PostController", action: "post"}
Post.js
module.exports = {
attributes: { val: { type: 'string', required: true, unique: true } } }
PostController.js (?)
module.exports = {
var bodyParser = require('body-parser');
var app = express();
app.post : function (req, res) {
var val = req.body.val;
return res.send ('val': val);
todo: 'Now how do I start loading into mongoDB ?';
}}
app.js
?
KEY QUESTION
How does val goes from the client to the database, that is :
what is the right sequence of events between component files in Sails ?