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

support 'mixinsources' option #131

Merged
merged 1 commit into from
May 7, 2015

Conversation

PradnyaBaviskar
Copy link
Contributor

In continuation with - #79, added support for mixinSources option.

The implementation -

  • By default looks for mixinsources in mixins directory
  • Loads only mixins used through models

Connect to #79

@bajtos - Can you review?

mixins = mixins.filter(function(m) {
return (includeMixins.indexOf(m.name) === -1 ? false : true);
});
}
Copy link
Member

Choose a reason for hiding this comment

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

I am proposing to move this filtering code out of "loadMixins" to keep "loadMixins" simpler and focused on doing one thing only.

@bajtos bajtos self-assigned this Apr 30, 2015
// Filter in only mixins, that are used in models
mixinsFromMixinSources = filterMixins(mixinsFromMixinSources, modelMixins);

mixins = mixins.concat(mixinsFromMixinSources);
Copy link
Member

Choose a reason for hiding this comment

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

This may create duplicate items in the mixins array, when the same mixin is loaded from mixinDirs and mixinSources, is that correct? In which case you should de-duplicate the instructions.

@PradnyaBaviskar
Copy link
Contributor Author

@bajtos - Addressed your comments above and have also added a few more test cases.

Can you please review?

var files = options.mixins || [];
var mixins = loadMixins(appRootDir, mixinDirs, files, extensions, options);
if (mixins === undefined) return;
Copy link
Member

Choose a reason for hiding this comment

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

I find this difficult to grasp at the first sight, it looks like loadMixins should be modifying the files variable.

@bajtos
Copy link
Member

bajtos commented May 5, 2015

The implementation looks good in general now, although I find it difficult to understand the implementation in compiler. Can you please try to simplify it a bit more, using my comments above for inspiration? Don't worry about it too much. If the result does not look better than the current solution or it takes too much time, then I am ok to land the patch as it is now.

@PradnyaBaviskar PradnyaBaviskar force-pushed the lb-issue-79-mixinsources branch 2 times, most recently from d460161 to 77c8c60 Compare May 6, 2015 13:29
@PradnyaBaviskar
Copy link
Contributor Author

@bajtos - Done with the changes suggested by you. Please review. 77c8c60

return mixins;
}

function findMixinDefinition(appRootDir, sourceDirs, extensions) {
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: please rename to findMixinDefinitions (plural).

- By default looks for mixinsources in  directory

- Loads only mixins used through models
@PradnyaBaviskar
Copy link
Contributor Author

Reworked on loadMixins, so that it returns lookup table, and not an array.

bajtos added a commit that referenced this pull request May 7, 2015
@bajtos bajtos merged commit 140180f into strongloop:master May 7, 2015
@bajtos
Copy link
Member

bajtos commented May 7, 2015

Awesome, landed!

@ramshgithub
Copy link

ramshgithub commented Dec 20, 2017

I am facing an issue as "column "columnname" does not exist", when i try to find any data from my Person table.I have 'name' and 'role' fields in my Person table, and 'status' is not present in my table(not require same in table).But my model.json have name,role and status as i needed all these fields in my explorer API.how can i solve this error?this happens whenever we have extra column name in model which is not present in our DB

Person.json

{
"name": "Person",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"name": {
"type": "string"
},
"status": {
"type": "string"
},
"role": {
"type": "string"
}
},
"validations": [],
"relations": {
"products": {
"type": "hasMany",
"model": "Product",
"foreignKey": "personId",
"description": "Returns a list of products associated with a person."
}
},
"methods": {}
}

@bajtos
Copy link
Member

bajtos commented Jan 8, 2018

@ramshgithub AFAICT, your issue is completely unrelated to 'mixinsources' option implemented by this pull request. Please open a new issue in LoopBack's main issue tracker: https://github.com/strongloop/loopback/issues/new

@strongloop strongloop locked and limited conversation to collaborators Jan 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants