mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
further typing improvements
This commit is contained in:
committed by
Thomas Ruoff
parent
90ac05a907
commit
52a68e9989
16
db/booker.ts
16
db/booker.ts
@@ -1,6 +1,16 @@
|
||||
import * as mongoose from 'mongoose'
|
||||
|
||||
const BookerSchema = new mongoose.Schema(
|
||||
export interface Booker
|
||||
extends mongoose.SchemaTimestampsConfig,
|
||||
mongoose.Document {
|
||||
name: string
|
||||
email: string
|
||||
street: string
|
||||
zip: string
|
||||
city: string
|
||||
}
|
||||
|
||||
const BookerSchema = new mongoose.Schema<Booker>(
|
||||
{
|
||||
name: { type: String, required: true },
|
||||
email: { type: String, required: true, unique: true, minlength: 5 },
|
||||
@@ -11,4 +21,6 @@ const BookerSchema = new mongoose.Schema(
|
||||
{ timestamps: true, collation: { locale: 'de', strength: 1 } }
|
||||
)
|
||||
|
||||
export default mongoose.models.Booker || mongoose.model('Booker', BookerSchema)
|
||||
const Model: mongoose.Model<Booker> =
|
||||
mongoose.models.Booker || mongoose.model('Booker', BookerSchema)
|
||||
export default Model
|
||||
|
||||
@@ -1,11 +1,24 @@
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import * as mongoose from 'mongoose'
|
||||
|
||||
import { getDays, dateFormatBackend } from '../helpers/date'
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
import { dateFormatBackend, getDays } from '../helpers/date'
|
||||
import { Booker } from './booker'
|
||||
import { BOOKING_STATUS } from './bookingStatus'
|
||||
|
||||
const BookingSchema = new mongoose.Schema(
|
||||
export interface Booking
|
||||
extends mongoose.Document,
|
||||
mongoose.SchemaTimestampsConfig {
|
||||
uuid: string
|
||||
booker: Booker
|
||||
startDate: Date
|
||||
endDate: Date
|
||||
status: string
|
||||
purpose: string
|
||||
org: string
|
||||
destination: string
|
||||
days?: string[]
|
||||
}
|
||||
|
||||
const BookingSchema = new mongoose.Schema<Booking>(
|
||||
{
|
||||
// need a seperate uuid to be able to target a booking anonimously
|
||||
uuid: {
|
||||
@@ -51,7 +64,7 @@ BookingSchema.virtual('days').get(function () {
|
||||
return getDays({ startDate: this.startDate, endDate: this.endDate })
|
||||
})
|
||||
|
||||
BookingSchema.virtual('hash').get(function () {})
|
||||
const Model: mongoose.Model<Booking> =
|
||||
mongoose.models.Booking || mongoose.model('Booking', BookingSchema)
|
||||
|
||||
export default mongoose.models.Booking ||
|
||||
mongoose.model('Booking', BookingSchema)
|
||||
export default Model
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import * as mongoose from 'mongoose'
|
||||
|
||||
import Booker from './booker'
|
||||
import Booking from './booking'
|
||||
import { BOOKING_STATUS } from './bookingStatus'
|
||||
|
||||
Reference in New Issue
Block a user