mirror of
https://github.com/FranP-code/shortly.git
synced 2025-10-13 00:43:28 +00:00
first working prototype of shortly
This commit is contained in:
34
src/models/schemas/Url.schema.ts
Normal file
34
src/models/schemas/Url.schema.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { model, Model, Schema } from 'mongoose'
|
||||
|
||||
export interface IUrl {
|
||||
id: string
|
||||
url: string
|
||||
dateCreated: Date
|
||||
uploadedByUser: string
|
||||
}
|
||||
|
||||
export const urlSchema = new Schema<IUrl>(
|
||||
{
|
||||
id: {
|
||||
type: String,
|
||||
unique: true,
|
||||
required: true,
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
dateCreated: {
|
||||
type: Date,
|
||||
default: new Date(),
|
||||
required: true,
|
||||
},
|
||||
uploadedByUser: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{ collection: 'url', timestamps: true }
|
||||
)
|
||||
|
||||
export const UrlModel: Model<IUrl> = model('Url', urlSchema)
|
||||
Reference in New Issue
Block a user