Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for options #11

Merged
merged 2 commits into from
May 1, 2017
Merged

Add support for options #11

merged 2 commits into from
May 1, 2017

Conversation

mnsn
Copy link
Contributor

@mnsn mnsn commented Apr 29, 2017

add support to ignore_getters_and_setter options so ecma6 that have
virtual properties that located in the schema will work
for instance if you have class

class User{
  get name (){
    return this._namel
  }
  set name(value){
    this._name=valuel
  }
}
const UserSchema = new Schema ({
  name:String
});
UserSchema.plugin(loadClass,User);

will throw an exception , let's let the user to decide if s/he wants to add virtual prorties or not

add support to ignore_getters_and_setter options so ecma6 that have
virtual properties that located in the schema will work
@@ -1,2 +1,2 @@
declare function loadClass(schema: any, target: any): void;
declare function loadClass(schema: any, {target: any,options: object}:object): void;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this work when developer uses it without options, like loadClass(schema, UserModel);?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I kept on backward compatibility

README.md Outdated
@@ -58,8 +58,13 @@ class UserModel {

}

//posible options, for instance if you want to ignore getter and setters put
options={
ignore_getters_and_setters:true
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please name options in camelCase, also use let or const for declaring options here.

src/index.js Outdated
@@ -1,6 +1,7 @@
'use strict';

function wrap(schema, target, hooks = []) {
function wrap(schema,params, hooks = []) {
let {options={},target=params} = params;
Copy link
Owner

@aksyonov aksyonov Apr 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make your code consistent with existing code (add space after , and :, around =, use 2 spaces for indentation).

@mnsn
Copy link
Contributor Author

mnsn commented May 1, 2017

Fixed the request changes

@aksyonov aksyonov merged commit c011c89 into aksyonov:master May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants