Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,18 @@ export type RegionStatsT = {
withoutContent: number;
withoutImg: number;
};

export type TripReportT = {
_id?: string;
locationId: string;
checklistId: string;
content: string;
distance?: string;
duration?: string;
species?: string;
profileId: string;
date: Date;
images: Image[];
createdAt: string;
updatedAt: string;
};
50 changes: 50 additions & 0 deletions models/TripReport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { TripReportT } from "lib/types";
import mongoose from "mongoose";
const { Schema, model, models } = mongoose;

type SchemaT = Record<keyof Omit<TripReportT, "_id" | "createdAt" | "updatedAt">, any>;

export const fields: SchemaT = {
locationId: {
type: String,
required: true,
},
checklistId: {
type: String,
required: true,
},
content: {
type: String,
required: true,
},
distance: String,
duration: String,
species: String,
profileId: {
type: String,
required: true,
},
date: {
type: Date,
default: Date.now,
required: true,
},
images: [
{
smUrl: String,
lgUrl: String,
originalUrl: String,
width: Number,
height: Number,
caption: String,
},
],
};

const TripReportSchema = new Schema(fields, {
timestamps: true,
});

const TripReport = models?.TripReport || model("TripReport", TripReportSchema);

export default TripReport as mongoose.Model<TripReportT>;
Loading