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
Post a Comment