summary refs log tree commit diff
path: root/src/db/schemas/sensorHistory.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/db/schemas/sensorHistory.js')
-rw-r--r--src/db/schemas/sensorHistory.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/db/schemas/sensorHistory.js b/src/db/schemas/sensorHistory.js
new file mode 100644

index 0000000..0cf1187 --- /dev/null +++ b/src/db/schemas/sensorHistory.js
@@ -0,0 +1,34 @@ +import { model, Schema, ObjectId } from 'mongoose'; + +/** + * User schema for MongoDB. + * @type {module:mongoose.Schema} + */ +export const sensorHistorySchema = new Schema( + { + createdAt: { + type: Date, + default: Date.now, + immutable: true + }, + sensor: { + type: String, + required: true, + immutable: true + }, + value: { + type: Number, + required: true, + immutable: true + } + }, + { + timeseries: { + timeField: 'createdAt' + } + } +); + +export const DbSpendHistory = model('sensorHistory', sensorHistorySchema); + +console.log('[MONGODB] sensorHistory schema initialized successfully!');