Reputation: 11
I have the following model definition in a loopback project: `
{
"name": "Program",
"base": "PersistedModel",
"properties": {
"sId": {
"type": "string",
"required": true,
"length": 20
},
"Category": {
"type": "string",
"length": 255,
"description": "Category"
},
"ProgramName": {
"type": "string",
"length": 255,
"description": "Program Name"
},
"Program_Status": {
"type": "string",
"length": 255,
"description": "Program Status"
}
},
"validations": [],
"relations": {
"account": {
"type": "belongsTo",
"model": "Account",
"foreignKey": "Account__c",
"primaryKey": "sId"
},
},
"methods": {}
}
`
I want to get value of description defined in field name in any other model. Is there anyway in loopback or express.js to get it?
Upvotes: 0
Views: 221
Reputation: 876
It's only possible via javascript
code. I'm afraid there isn't a way to access json
files properties from another json
file.
In yourOtherModel.js
module.exports = function(yourOtherModel){
var programProps = yourOtherModel.app.models.Program.properties;
//Your props
var programDescription = programProps.Category.description;
}
Upvotes: 0