-
Notifications
You must be signed in to change notification settings - Fork 234
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
Indexes are not created when declared in Model JSON #103
Comments
You'll have to run |
@raymondfeng Thanks for the quick response. Saved my day! |
@raymondfeng If that is the case shouldn't it be included as one of the boot scripts by default? |
I tried automigrate and autoupdate at boot scripts
Then all data of Product lost without preserve |
Use autoupdate, NOT automigrate. |
Thanks 👍 |
for what it worth here is my autoupdate script: 'use strict';
global.Promise = require('bluebird');
module.exports = function(server) {
Promise.each(server.models(), function(model) {
if (model.dataSource) {
var autoupdate = Promise.promisify(model.dataSource.autoupdate);
if (autoupdate) {
return autoupdate.call(model.dataSource, model.modelName);
}
}
});
}; |
Closing this issue as its been resolved. |
@thaiat thanks for the script. works like a charm. but what if you remove an index definition from a model.json? I recognized that indexes are not removed from db. @raymondfeng should autoupdate be a loopback boot script which is called on every boot? |
@thaiat I'm getting this error when the script is executed. Yet the indexes are created. |
@michaelfreund have you found solution for remove an index from db when remove from model.json? |
I just want to check whether creating indexes feature has been implemented or not. I followed documentation on http://docs.strongloop.com/display/public/LB/Model+definition+JSON+file#ModeldefinitionJSONfile-Indexes and tried to declare the following index in my model json file:
But when I check MongoDB, I don't see this index being generated.
The text was updated successfully, but these errors were encountered: