import { Schema } from "mongoose"; const AnonymizedGistSchema = new Schema({ accessAlertGeneration: { type: String, select: false }, accessAlertClaimedAt: { type: Date, select: false }, accessAlertAttemptId: { type: String, select: false }, accessAlertClaimRevision: { type: Number, select: false }, gistId: { type: String, index: { unique: true }, }, status: { type: String, default: "preparing", }, statusDate: Date, statusMessage: String, anonymizeDate: Date, lastView: Date, pageView: Number, owner: { type: Schema.Types.ObjectId, index: true }, conference: String, source: { gistId: String, accessToken: { type: String, select: false }, }, options: { terms: [String], expirationMode: { type: String }, expirationDate: Date, update: Boolean, image: Boolean, link: Boolean, title: Boolean, body: Boolean, comments: Boolean, content: Boolean, origin: Boolean, username: Boolean, date: Boolean, }, dateOfEntry: { type: Date, default: Date.now, }, gist: { description: String, isPublic: Boolean, creationDate: Date, updatedDate: Date, ownerLogin: String, files: [ { filename: String, content: String, language: String, size: Number, // `type` is a reserved key in Mongoose type declarations; without the // nested `{ type: String }` the whole object is compiled as an array // of strings and file objects are silently dropped on save. type: { type: String }, }, ], comments: [ { body: String, creationDate: Date, updatedDate: Date, author: String, }, ], }, }); AnonymizedGistSchema.index({ status: 1, "options.expirationDate": 1 }); export default AnonymizedGistSchema;