Promise in getterMethods
See original GitHub issueI wanna do the following getter in my model:
getterMethods: {
objectLabel: function() {
if (this.zoneId) {
db.WarehouseZone.findOne({
where: {
id: this.zoneId
}
}).then(zone => {
return `${zone.zoneId}-${this.aisle}-${this.bin}-${this.level}`;
});
} else {
return `${this.aisle}-${this.bin}-${this.level}`;
}
return `${this.zoneId ? `${this.zoneId}-` : ''}${this.aisle}-${this.bin}-${this.level}`;
}
}
How can I do that with promises? Is here exists any callback or something other?
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (7 by maintainers)
Top Results From Across the Web
Async Getters and Setters. Is it Possible? | by David Barral
Async functions always return a promise. If the return value of an async function is not explicitly a promise, it will be implicitly...
Read more >Async getterMethods in sequelize - node.js - Stack Overflow
The getterMethod is synchronous so you would not be able to run a promise and return the resolved value on the model instance....
Read more >getter - JavaScript - MDN Web Docs - Mozilla
Getter properties are defined on the prototype property of the class and are thus shared by all instances of the class. Unlike getter...
Read more >T287 Use promises for image info getter methods in ...
Use promises for image info getter methods in UploadWizardUpload. Closed, DuplicatePublic. Actions. Edit Task; Edit Related Tasks.
Read more >JavaScript Getter and Setter (with Examples) - Programiz
In JavaScript, getter methods are used to access the properties of an object. For example,. const student = { // data property firstName:...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Works fine for me
Please try to create a SSCCE - its really, really hard to help you if I can’t replicate the problem
Please read the link on SSCCE and post a complete, self-contained, copy paste-able test case that replicates the issue