19 lines
503 B
JavaScript
19 lines
503 B
JavaScript
import mongoose from "mongoose";
|
|
|
|
const wateringSessionSchema = new mongoose.Schema(
|
|
{
|
|
deviceId: { type: mongoose.Schema.Types.ObjectId, ref: "Device", default: null },
|
|
patchIds: { type: [String], default: [] },
|
|
startedAt: { type: Date, required: true },
|
|
endedAt: { type: Date, default: null },
|
|
},
|
|
{ timestamps: true },
|
|
);
|
|
|
|
wateringSessionSchema.index({ endedAt: 1, startedAt: -1 });
|
|
|
|
export const WateringSession = mongoose.model(
|
|
"WateringSession",
|
|
wateringSessionSchema,
|
|
);
|