scottwrobinson / camo

A class-based ES6 ODM for Mongo-like databases.
556 stars 80 forks source link

Why use .create() for instantiation? #71

Open TheCodeDestroyer opened 8 years ago

TheCodeDestroyer commented 8 years ago

So from the examples I see that we need to use Class.create() method to create a new instance is there a reason why this can't be handled in Document constructor, so we could use it like this let newClass = new Class(); since we already call super either way?

scottwrobinson commented 8 years ago

This is a good question. I originally had to use .create() because in the first few versions of Camo it was using Proxies underneath. The proxy had to be set up on an object instance and not the class object. So .create() was used to set up the Proxy and has been carried over from those older versions.

Now that proxies aren't being used anymore, .create() probably isn't required. I'll look in to it and possibly deprecate it in the next version.

Thanks for bringing this up!

TheCodeDestroyer commented 8 years ago

Awesomesauce!

jampy commented 8 years ago

+1

Any idea when this will be released?