Skip to content
This repository has been archived by the owner on Feb 10, 2022. It is now read-only.

Alterative to old middleware create hooks example #209

Open
wesleycoder opened this issue Feb 5, 2018 · 1 comment
Open

Alterative to old middleware create hooks example #209

wesleycoder opened this issue Feb 5, 2018 · 1 comment

Comments

@wesleycoder
Copy link

wesleycoder commented Feb 5, 2018

I'm struggling trying to get a clean solution for the create hook from previous version.

Before if we wanted to make any modification to the data before creating the instance on the model we could follow the example here but in this version it is not clear what should be the solution for it.

I've looked into the examples of middlewares here but could not understand how it should work.

I think the documentation on Readme.md should clarify this a little bit more.

How could I make the same thing that the old docs describe since the configure method is not being called anymore?

@wesleycoder
Copy link
Author

wesleycoder commented Feb 6, 2018

I'm currently working on something like:

export class Player extends Model {
  constructor (data) {
    super(data)
    if (!this.isSaved()) {
      this.set('password', this._cryptPassword(this.get('password')))
    }
  }
  //...
}

Is this a good way of doing it or using middlewares would be a better approach?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant