35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const contentCollectionSchema = new mongoose.Schema(
|
|
{
|
|
organization: {
|
|
type: mongoose.Schema.Types.ObjectId,
|
|
ref: 'Organization',
|
|
required: true,
|
|
},
|
|
name: { type: String, required: true },
|
|
description: { type: String, default: '' },
|
|
collectionType: { type: String, default: '' },
|
|
coverIcon: { type: String, default: '' },
|
|
tags: [{ type: String }],
|
|
contentIds: [{ type: mongoose.Schema.Types.ObjectId, ref: 'LibraryContent' }],
|
|
visibility: {
|
|
type: String,
|
|
enum: ['private', 'shared', 'public'],
|
|
default: 'private',
|
|
},
|
|
sharedWith: [{ type: mongoose.Schema.Types.ObjectId, ref: 'User' }],
|
|
passwordProtected: { type: Boolean, default: false },
|
|
passwordHash: { type: String, default: '' },
|
|
expiryEnabled: { type: Boolean, default: false },
|
|
expiryDate: Date,
|
|
notifyOnAdd: { type: Boolean, default: true },
|
|
notifyOnShare: { type: Boolean, default: true },
|
|
createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
|
|
},
|
|
{ timestamps: true }
|
|
);
|
|
|
|
contentCollectionSchema.index({ organization: 1, createdAt: -1 });
|
|
module.exports = mongoose.model('ContentCollection', contentCollectionSchema);
|