You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.0 KiB
79 lines
2.0 KiB
// status.js
|
|
// Copyright (C) 2024 DTP Technologies, LLC
|
|
// All Rights Reserved
|
|
|
|
'use strict';
|
|
|
|
import mongoose from 'mongoose';
|
|
const Schema = mongoose.Schema;
|
|
|
|
const LinkSchema = new Schema({
|
|
created: { type: Date, default: Date.now, required: true, index: -1, },
|
|
lastShared: { type: Date, required: true, index: -1 },
|
|
lastPreviewFetched: { type: Date },
|
|
submittedBy: { type: [Schema.ObjectId], required: true, index: 1, ref: 'User' },
|
|
domain: { type: String, lowercase: true, required: true },
|
|
url: { type: String, required: true },
|
|
title: { type: String },
|
|
siteName: { type: String },
|
|
description: { type: String },
|
|
tags: { type: [String] },
|
|
mediaType: { type: String },
|
|
contentType: { type: String },
|
|
images: { type: [String] },
|
|
videos: { type: [String] },
|
|
audios: { type: [String] },
|
|
favicons: { type: [String] },
|
|
oembed: {
|
|
href: { type: String },
|
|
fetched: { type: Date, required: true },
|
|
version: { type: String },
|
|
type: { type: String },
|
|
cache_age: { type: Number },
|
|
title: { type: String },
|
|
provider_name: { type: String },
|
|
provider_url: { type: String },
|
|
author_name: { type: String },
|
|
author_url: { type: String },
|
|
thumbnail_url: { type: String },
|
|
thumbnail_width: { type: String },
|
|
thumbnail_height: { type: String },
|
|
html: { type: String },
|
|
url: { type: String },
|
|
width: { type: String },
|
|
height: { type: String },
|
|
},
|
|
flags: {
|
|
isBlocked: { type: Boolean, default: false, required: true },
|
|
havePreview: { type: Boolean, default: false, required: true },
|
|
},
|
|
stats: {
|
|
shareCount: { type: Number, default: 1, required: true },
|
|
visitCount: { type: Number, default: 0, required: true },
|
|
},
|
|
});
|
|
|
|
LinkSchema.index({
|
|
domain: 1,
|
|
url: 1,
|
|
}, {
|
|
unique: true,
|
|
name: 'link_domain_unique',
|
|
});
|
|
|
|
LinkSchema.index({
|
|
title: 'text',
|
|
description: 'text',
|
|
siteName: 'text',
|
|
domain: 'text',
|
|
}, {
|
|
weights: {
|
|
title: 5,
|
|
siteName: 3,
|
|
domain: 2,
|
|
description: 1,
|
|
},
|
|
name: 'link_text_idx',
|
|
});
|
|
|
|
export default mongoose.model('Link', LinkSchema);
|