mirror of
https://github.com/franjsco/trackmyd-api
synced 2025-06-06 00:29:14 +02:00
add deviceModel
This commit is contained in:
53
models/deviceModel.js
Normal file
53
models/deviceModel.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
const mongoose = require('mongoose');
|
||||||
|
|
||||||
|
const device = {
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
lastUpdate: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
position: {
|
||||||
|
latitude: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
longtitude: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
altitude: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
speed: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
accurancy: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
information: {
|
||||||
|
battery: {
|
||||||
|
type: String,
|
||||||
|
required: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const deviceSchema = mongoose.Schema(device, {
|
||||||
|
collection: 'devices',
|
||||||
|
versionKey: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
const Device = mongoose.model('device', deviceSchema);
|
||||||
|
|
||||||
|
module.exports = Device;
|
||||||
|
|
||||||
|
module.exports.get = (callback, limit) => {
|
||||||
|
Device.find(callback).limit(limit);
|
||||||
|
};
|
Reference in New Issue
Block a user