Compare commits

...

1 Commits

Author SHA1 Message Date
Julien Fontanet
4bd7a76d47 feat(xen-api/Record#resolve_): resolve props named as types 2021-04-07 16:00:35 +02:00

View File

@@ -1111,6 +1111,13 @@ export class Xapi extends EventEmitter {
const value = this[field]
return value.length === 0 ? value : value.map(getObjectByRef)
}
let relationType
if (field[field.length - 1] === 's' && this._types.includes((relationType = field.slice(0, -1)))) {
props[`resolve_${field}`] = function () {
return xapi.getRecords(relationType, this[field])
}
}
}
props[`add_${field}`] = function (value) {
@@ -1137,6 +1144,12 @@ export class Xapi extends EventEmitter {
getters[$field] = function () {
return xapi._objectsByRef[this[field]]
}
if (this._types.includes(field)) {
props[`resolve_${field}`] = function () {
return xapi.getRecord(field, this[field])
}
}
}
})
const descriptors = {}