Saturday 22 April 2017

SailsJS / Waterline: Can I access database fields for my models without specifying every attribute?

I'm using SailsJs for my application. I have an existing database and I want to avoid mapping all existing fields as attributes for my models.

Is it possible to access database fields from my model without explicitly specifying every field as an attribute for my Model, the way Laravel, Rails or AdonisJS does?

For example:

I have the model User.js, I want to avoid setting:

module.exports = {
    attributes: {
        name: {
           type: 'string'
        },
        email: {
            type: 'string'
        },

        .....

    }
};

I just be able to access user.email because that field exists in the table.



via Agu Dondo

No comments:

Post a Comment