Skip to content

Instantly share code, notes, and snippets.

@bvenkatr
Created July 13, 2017 03:43
Show Gist options
  • Save bvenkatr/97ecf602e564efab3e134f0ddf92c03d to your computer and use it in GitHub Desktop.
Save bvenkatr/97ecf602e564efab3e134f0ddf92c03d to your computer and use it in GitHub Desktop.
'use strict';
module.exports = function (Todos) {
Todos.validatesLengthOf('text', {min: 5, message: {min: 'text is too short'}});
//create a test remote method and do field validations using Validate object
Todos.saveTodosData = function (text, done, cb) {
Todos.create({text, done}, function (err, data) {
cb(err, data);
});
};
Todos.remoteMethod("saveTodosData", {
accepts: [
{
arg: "text",
type: "string",
required: true
}, {
arg: "done",
type: "boolean",
required: true
}
],
returns: {
root: true
}
});
};
curl -H "Content-Type: application/json" -X POST -d '{"text":"30","done":false}' http://localhost:3001/rzr/api/todos/saveTodosData
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment