Update schema.ts

This commit is contained in:
Oskar 2021-09-15 22:23:56 +02:00 committed by GitHub
parent 2e828b688d
commit c197421ac3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -12,12 +12,12 @@ const schema = new Schema<URL>({
}
})
schema.path('url').validate(async function(value) {
schema.path('urls').validate(async function(value) {
const count = await models.URL.countDocuments({ url: value })
return !count
}, 'URL already exists')
const URLModel = model<URL>('URL', schema)
const URLModel = model<URL>('urls', schema)
export = URLModel