This repository has been archived on 2026-10-08. You can view files and clone it, but cannot push or open issues or pull requests.
allotment/packages/server/db/models/WateringSession.schema.js

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,
);