juampi92/adonis-mongoose-model

question: adonis model functionalities

unairubio opened this issue · 1 comments

Hey, thanks for keeping this up.

Considering using this for a large project but there a few things from the documentation that are not apparent:

  • I am assuming that a model, say Person, will now have access to the mongoose queries? Say Person.findOne({ 'name.last': 'Ghost' }). If so that'd be great to have a section on the documentation with a couple of examples.
  • What about JWT authentication? Is it supported? Does the auth.getUser() helper work?
  • What about adonis traits - any support for those?

Thanks!

Edit: I can confirm the auth helpers getUser() and attemp() work as intended.

The core purpose of this package is to do a easy interface to Mongoose models. So yes, the output model is in fact a Mongoose model, and you have all it's properties.

It also includes some default methods for integrating the models with (for example) the serialization (using objectId instead of autoincrements, etc).

You can check this line:
https://github.com/juampi92/adonis-mongoose-model/blob/master/src/Model/Base.js#L151 that shows what's being done when you export the model.

I didn't find any point on adding Mongoose documentation on this repo's documentation, buy maybe if you consider it will help new package users to understand the scope, you're more than welcome to add a PR that points developers in the right path :)

And I didn't try the traits myself, but since I don't think they are adonis-model specific, I think they should work. Just call them on the static boot method, just like the documentation says.