UNPKG

@gameroom/cli

Version:

A command line tool for Gameroom

21 lines (19 loc) 653 B
const { models } = require('@gameroom/kit') module.exports = class Image { constructor(data) { if (!data) data = {} this.created_at = data.created_at this.height = data.height this.id = data.id this.position = data.position this.product_id = data.product_id this.src = data.src this.updated_at = data.updated_at this.variant_ids = data.variant_ids this.width = data.width } static async fromUnit(unit) { const images = await models.Image.get({ filter: { key: 'imageable_id', value: unit.id }, sort: [{ position: 1 }] }) return images.reduce((a, i) => [...a, new Image({ src: i.image })], []) } }