Skip to content
This repository has been archived by the owner on Jun 29, 2021. It is now read-only.

[Question] Comparison to loadClass() #246

Closed
lonix1 opened this issue Feb 15, 2019 · 2 comments
Closed

[Question] Comparison to loadClass() #246

lonix1 opened this issue Feb 15, 2019 · 2 comments

Comments

@lonix1
Copy link

lonix1 commented Feb 15, 2019

Please forgive the new question.

Apparently mongoose allows creation of models from ES6 classes.

I realise ES6 is not TypeScript. However I'm trying to decide which approach to take, and don't understand the benefits of each one.

Are there extra benefits to using typegoose that I won't get if I go with loadClass()?

@hasezoey

This comment has been minimized.

hasezoey referenced this issue in typegoose/typegoose Aug 7, 2019
- use schema.loadClass() instead of self-handling it
- breaking many things
- adding docs for virtual-populate
- deprecating method decorators
- deprecating setModelForClass
- moving _buildSchema to its own file
- adding error tests
- adding more errors
- rebuilding how schema generation works
- adding more docs to VirtualOptions
- adding "count" to VirtualOptions

fixes szokodiakos#48
fixes szokodiakos#28
fixes szokodiakos#246
fixes szokodiakos#182
@hasezoey hasezoey mentioned this issue Aug 7, 2019
14 tasks
@hasezoey
Copy link
Contributor

hasezoey commented Sep 2, 2019

I know this is an old question, but i will answer more detailed anyway

With version 6.0.0, typegoose uses loadClass()

What loadClass can do:

  • load getters & setters (as virtuals)
  • load static methods
  • load instance methods

What loadClass cannot do:

  • make properties, that why @prop in typegoose exists
  • make virtual populates
  • make non-virtual getters and setters
  • make schema Options as a decorator
  • make indexes as a decorator

otherwise why i marked the issue as a duplicate at first, was a small mistake
but with v6.0.0 it is being used

@Ben305 this can be closed

@lonix1 lonix1 closed this as completed Sep 3, 2019
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

2 participants