You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for the suggestion, Ryan! Unfortunately static properties aren't available in Node right now, and as much as I'd like to use Babel I don't think it would be reasonable to require the user to do so also.
Instead I've been thinking we should just do something like this:
'use strict';classDocument{constructor(){}staticcollectionName(){returnthis.name.toLowerCase();}}classPersonextendsDocument{constructor(){super();}staticcollectionName(){return'people';}}classBillextendsPerson{constructor(){super();}}console.log('Document:',Document.collectionName());// Prints 'document'console.log('Person:',Person.collectionName());// Prints 'people'console.log('Bill:',Bill.collectionName());// Prints 'people'
Requiring the user to add the collectionName() function isn't as good as using a property, but it's better than what we're doing now. Also, if collectionName() isn't provided we just use the class name by default (and optionally with Pluralize to make it look nicer).
You asked how to do this better here: https://github.com/scottwrobinson/camo/blob/master/lib/document.js#L41
Just use a static property
static collectionName = 'people';
instead of usingsuper('people')
.Then your
Document
class can dothis.constructor.collectionName
to access it.http://jsfiddle.net/resistdesign/wgsh2sex/
The text was updated successfully, but these errors were encountered: