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/Device.schema.js

16 lines
477 B
JavaScript

import mongoose from "mongoose";
const deviceSchema = new mongoose.Schema(
{
name: { type: String, required: true },
ttnApplicationId: { type: String, default: null, index: true },
ttnDeviceId: { type: String, default: null, index: true },
online: { type: Boolean, default: false },
},
{ timestamps: true },
);
deviceSchema.index({ ttnApplicationId: 1, ttnDeviceId: 1 }, { sparse: true });
export const Device = mongoose.model("Device", deviceSchema);