blob: e0160798e5619cc20b303eaab31c1e2b9e626c8d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import { model, Schema, ObjectId } from 'mongoose';
/**
* User schema for MongoDB.
* @type {module:mongoose.Schema}
*/
export const sensorHistorySchema = new Schema(
{
sensor: {
type: String,
required: true,
immutable: true
},
value: {
type: Number,
required: true,
immutable: true
}
},
{
timestamps: {
createdAt: true,
updatedAt: false
},
timeseries: {
timeField: 'createdAt'
}
}
);
export const DbSensorHistory = model('sensorHistory', sensorHistorySchema);
console.log('[MONGODB] sensorHistory schema initialized successfully!');
|