Nest intial code
This commit is contained in:
commit
7b299ae5b5
8 changed files with 2217 additions and 0 deletions
27
modules/shortUrl.js
Normal file
27
modules/shortUrl.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import mongoose from "mongoose";
|
||||
import { nanoid } from "nanoid";
|
||||
|
||||
const shortUrlSchema = new mongoose.Schema(
|
||||
{
|
||||
full: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
},
|
||||
short: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true,
|
||||
default: () => nanoid(6),
|
||||
},
|
||||
clicks: {
|
||||
type: Number,
|
||||
required: true,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
{ timestamps: true }
|
||||
);
|
||||
|
||||
const ShortUrl = mongoose.model("ShortUrl", shortUrlSchema);
|
||||
export default ShortUrl;
|
Loading…
Add table
Add a link
Reference in a new issue