Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Creating a model with name "model" causes issues #195

Closed
Ziao opened this issue Oct 13, 2019 · 0 comments · Fixed by feathersjs-ecosystem/generator-feathers#494
Closed

Comments

@Ziao
Copy link

Ziao commented Oct 13, 2019

Steps to reproduce

When adding a new service using feathers generate service and calling the service model, the following service file is generated.

// Initializes the `model` service on path `/model`
const { Model } = require('./model.class');
const createModel = require('../../models/model.model');
const hooks = require('./model.hooks');

module.exports = function(app) {
    const Model = createModel(app);
    const paginate = app.get('paginate');

    const options = {
        Model,
        paginate,
    };

    // Initialize our service with any options it requires
    app.use('/model', new Model(options, app));

    // Get our initialized service so that we can register hooks
    const service = app.service('model');

    service.hooks(hooks);
};

This causes an issue, as wit hin the exported function, a local variable with the same name is created. An easy fix is of course to rename either one of the two, but it may be good to make sure this doesn't happen, as I can imagine model isn't that uncommon of a name for a service.

Expected behavior

No issues

Actual behavior

Issue as described above.

System configuration

Module versions (especially the part that's not working):
@feathersjs/cli 4.2.1

NodeJS version:

Operating System:

Browser Version:

React Native Version:

Module Loader:

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 a pull request may close this issue.

1 participant