// image.js
// Copyright (C) 2022 DTP Technologies, LLC
// License: Apache-2.0

'use strict';

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const ImageSchema = new Schema({
  created: { type: Date, default: Date.now, required: true, index: -1 },
  owner: { type: Schema.ObjectId, required: true, index: 1, ref: 'User' },
  type: { type: String, required: true },
  size: { type: Number, required: true },
  file: {
    bucket: { type: String, required: true },
    key: { type: String, required: true },
    etag: { type: String, required: true, index: true },
  },
  metadata: {
    format: { type: String },
    size: { type: Number },
    width: { type: Number },
    height: { type: Number },
    space: { type: String },
    channels: { type: Number },
    depth: { type: String },
    density: { type: Number },
    hasAlpha: { type: Boolean },
    orientation: { type: Number },
  },
});

module.exports = mongoose.model('Image', ImageSchema);