node.js - Using Model method waterline -


i'm starting koa , waterline orm. have problem when try use "testfucntion" method waterline model controller:

"use strict"; //https://github.com/balderdashy/waterline-docs var waterline = require('waterline'); var bcrypt = require('bcrypt');  var user = waterline.collection.extend({     identity: 'user',     connection: 'default',     attributes: {         username: {             type: 'string',             required: true,         },         password: {             type: 'string',             minlength: 6,             maxlength: 21         }     },      //test function     testfucntion: function *(params) {         ...         console.log('inside');     } }); 

the code i'm using execute method :

function *(){     var params= this.request.body     var usermodel = this.models.user;     var result = yield usermodel.testfucntion(params) } 

i dont know if kind of functions public , how can use outside...

the custom methods on model need go under attributes node. have model specification , event lifecycle methods (we make mistake @ first).


Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -