0

How do I delete Loopback Models which are generated with the CLI?

I deleted the .js and .json files in the model-folder and also the lines in model-config.json. (which is said here: Destroy a model in loopback.io )

I still get the "model not found" error.

So the models seem to be registered somewhere else and the following code is throwing the error. Do you have any idea where to delete the models completly?

node_modules\loopback\lib\registry.js:

**
 * Look up a model class by name from all models created by
 * `loopback.createModel()`. **Throw an error when no such model exists.**
 *
 * @param {String} modelOrName The model name or a `Model` constructor.
 * @returns {Model} The model class
 *
 * @header loopback.getModel(modelName)
 */
Registry.prototype.getModel = function(modelName) {
  var model = this.findModel(modelName);
  if (model) return model;

  throw new Error(g.f('Model not found: %s', modelName));
};

If its important: i am using a mongoDB and the mongo-connector.

EliasPh
  • 43
  • 10
  • have you checked all parts of your code to see if you have used that model or not? (one thing you may haven't checked is relations...have you checked other models that may have a relationship with this model?) – tashakori Nov 07 '18 at 18:01
  • Thanks for the fast answer! I checked my code. i dont use the model anymore. its also not in the relations-part of the .json or .js files of my other models. i created relations also with the CLI but thought i deleted them with the model-files – EliasPh Nov 08 '18 at 13:52
  • i used the app.deleteModelByName(modelName) in a bootscript and it works now. – EliasPh Nov 08 '18 at 14:25

0 Answers0