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