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

'use strict';

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const UserArchiveSchema = new Schema({
  created: { type: Date, default: Date.now, required: true, index: -1 },
  user: {
    _id: { type: Schema.ObjectId, required: true, index: 1 },
    email: { type: String },
    username: { type: String, required: true },
  },
  archive: {
    bucket: { type: String, required: true },
    key: { type: String, required: true },
    etag: { type: String, required: true },
    size: { type: Number, required: true },
  },
  notes: { type: String },
});

module.exports = (conn) => {
  return conn.model('UserArchive', UserArchiveSchema);
};