Page MenuHomeSealhub

sealious-response.js
No OneTemporary

sealious-response.js

const ReferenceField = require("../sealious_response_fields/reference-field.js");
module.exports = class SealiousResponse {
constructor({ items, attachments, fieldsWithAttachments }) {
this._attachments = attachments;
this._fieldsWithAttachments = fieldsWithAttachments;
this._wrapFields(items);
}
getMetadata() {
return this._fieldsWithAttachments;
}
getAttachments() {
return this._attachments;
}
toObject() {}
_wrapFields(items) {
const fieldsWithAttachments = this._fieldsWithAttachments || {};
for (let item of items) {
for (let field of Object.keys(fieldsWithAttachments)) {
this._wrapSingleField(item, field);
}
}
}
_wrapSingleField(item, field) {
const fieldsWithAttachments = this._fieldsWithAttachments[field];
item[field] = Array.isArray(item[field])
? item[field].map(id =>
ReferenceField.make(
this._attachments,
fieldsWithAttachments,
id,
field
)
)
: ReferenceField.make(
this._attachments,
fieldsWithAttachments,
item[field],
field
);
}
};

File Metadata

Mime Type
text/plain
Expires
Fri, Nov 28, 15:04 (1 d, 20 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1073393
Default Alt Text
sealious-response.js (1 KB)

Event Timeline