Open fiftoine opened 6 years ago
Considering this situation:
lux new testApp --database mysql lux g resource user email:string password:string
lux new testApp --database mysql
lux g resource user email:string password:string
Updated routes.js
this.resource('users', function () { this.post('/emails', 'emails'); });
Added scope to model
class User extends Model { static scopes = { findByEmail(email) { return this.first().where({ email: email }); } }; }
Added method to controller
class UsersController extends Controller { params = [ 'email', 'password' ]; query = [ 'data' ]; emails({ params: { data: { attributes: { identification } } } }) { return User.findByEmail(identification); } }
When I POST http://localhost:4000/users/emails with body {"data":{"attributes":{"identification":"xxx@yyy.com"}}}
I receive a 500 with response :
{ "errors": [ { "status": "500", "title": "Internal Server Error", "detail": "User.findByEmail is not a function" } ], "jsonapi": { "version": "1.0" } }
What is wrong in the situation for the method findByEmail not to be found? This scope method should be callable from the controller no?
Considering this situation:
lux new testApp --database mysql
lux g resource user email:string password:string
Updated routes.js
Added scope to model
Added method to controller
When I POST http://localhost:4000/users/emails with body {"data":{"attributes":{"identification":"xxx@yyy.com"}}}
I receive a 500 with response :
What is wrong in the situation for the method findByEmail not to be found? This scope method should be callable from the controller no?