Open bhargavkn opened 3 years ago
@bhargavkn Thanks for posting! We'll take a look as soon as possible.
In the mean time, there are a few ways you can help speed things along:
Please remember: never post in a public forum if you believe you've found a genuine security vulnerability. Instead, disclose it responsibly.
For help with questions about Sails, click here.
Hi @bhargavkn, you can access the columnName
of attributes by calling [Model].schema.[attribute].columnName
. For your example, the way to access the columnName
of the id
attribute would be User.schema.id.columnName
.
@eashaw That worked, thanks!
Please feel free to close this issue.
PS: Apologies for the late reply here.
I'm unable to access the
columName
property from a Model's attributes in sails from other places in the code.Here's an example illustrating this:
module.exports = { tableName: 'users', attributes: { id: { type: 'string', columnType: 'varchar(40)', autoIncrement: true, columnName: 'user_id' } } };
Can someone help me in understanding what I'm missing here and how I can go about accessing the
columnName
property from the model?I felt it'd be easier to use the
columnName
property from the model and treating it as the source of truth instead of having to declare constants elsewhere (when creating a custom query, for example) that store the column names -- which is exactly what I'm trying to do.For anyone who wants to debug this, I've put up the example sails application here: https://github.com/bhargavkn/sails-sample
Node version: v14.15.4: Sails version: 1.4.0 (sails): ORM hook version: 2.1.1 (sails-hook-orm): Sockets hook version: NA (sails-hook-sockets): Organics hook version: NA (sails-hook-organics): Grunt hook version: NA (sails-hook-grunt): Uploads hook version: NA (sails-hook-uploads): DB adapter & version: 1.0.1 (e.g. sails-mysql@5.55.5): Skipper adapter & versionL: NA (e.g. skipper-s3@5.55.5):