Created the ShortenedLink model
This commit is contained in:
parent
0f623486ce
commit
5d192dc12a
35
models/ShortenedLink.ts
Normal file
35
models/ShortenedLink.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import mongoose, {Schema} from 'mongoose';
|
||||
import * as crypto from "crypto";
|
||||
|
||||
export interface IShortenedLink {
|
||||
shortenedId: string
|
||||
originalUrl: string
|
||||
clientId: number
|
||||
clicks: number
|
||||
created: Date
|
||||
}
|
||||
|
||||
const ShortenedSchema = new Schema<IShortenedLink>({
|
||||
shortenedId: {
|
||||
type: String,
|
||||
default: crypto.randomBytes(12).toString('hex')
|
||||
},
|
||||
originalUrl: {
|
||||
type: String,
|
||||
required: true
|
||||
},
|
||||
clientId: {
|
||||
type: Number,
|
||||
required: true
|
||||
},
|
||||
clicks: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
created: {
|
||||
type: Date,
|
||||
default: Date.now
|
||||
}
|
||||
});
|
||||
|
||||
export const ShortenedLink = mongoose.model('shortened_links', ShortenedSchema);
|
Loading…
x
Reference in New Issue
Block a user