Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add model instances' method #250

Closed
JunQiGenYuan opened this issue Sep 19, 2017 · 2 comments
Closed

add model instances' method #250

JunQiGenYuan opened this issue Sep 19, 2017 · 2 comments
Assignees
Labels
issue: discussion A general discussion issue

Comments

@JunQiGenYuan
Copy link

JunQiGenYuan commented Sep 19, 2017

version: v3.0

Is it a way to add custom to model instance that find or create?

If no, then I think could add code below into the strapi-mongoose

if (!_.isEmpty(definition.methods)) {
  _.forEach(definition.methods, (fn, methodName) => {
    collection.schema.method(methodName, fn);
  })
}

at

and use like this in [model].js:

module.exports = {
  methods: {
    validatePassword: function () {  ...some code goes here... }
  },
...
}
@Aurelsicoko
Copy link
Member

Interesting... I like the idea but you can also use a service for that? Our goal is not to override the ORM we are using such as Mongoose or Bookshelf to be able to follow the new releases and patches the maintainers are doing on them.

@lauriejim lauriejim added the v3.0 label Nov 8, 2017
@Aurelsicoko Aurelsicoko added the issue: discussion A general discussion issue label Nov 8, 2017
@Aurelsicoko
Copy link
Member

I'm closing this issue, feel free to submit this feature request on the Community Vote page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: discussion A general discussion issue
Projects
None yet
Development

No branches or pull requests

3 participants