scottwrobinson / camo

A class-based ES6 ODM for Mongo-like databases.
557 stars 81 forks source link

Possible to use Camo with a non-ES6 codebase? #32

Open JamesMGreene opened 8 years ago

JamesMGreene commented 8 years ago

Is there any easy way to use Camo with a non-ES6 codebase (Node.js standard CommonJS-style modules)? I would love to use it but I cannot switch our codebase over to ES6 modules as of yet (nor can I move to Node.js >= 2.x as of yet).

scottwrobinson commented 8 years ago

Hi James,

As of right now the only way you could use Camo with a non-ES6 codebase is if you used Babel (or some other transpiler), and even then there are some issues. Due to issue #17, I'm considering converting all internal Camo classes to be prototype-based, but I first need to see if prototype-based classes are compatible with ES6 classes - I have never mixed the two.

Hopefully I can get back to you on this within the week. Suggestions and feedback are welcome!

Thanks!

minecrawler commented 8 years ago

@scottwrobinson ES6 classes are compatible with prototyping. At the moment I am experimenting with a code architecture based on C++ classes. I am using this architecture at work and I also use it for one of my FOSS projects (and will restructure the others later on). You can find a detailed explanation here and the FOSS project here. As you can see in the readme, the interface uses an ES6 class, but in the code-files I overwrite the class' methods with prototype functions, nicely splitting the interface and the actual code. ES6 classes are nothing more than syntactical sugar after all :)