From 64aa61a02798a517d72f365a4f244b31a8d5eb82 Mon Sep 17 00:00:00 2001 From: Francesco Esposito <33671357+frab1t@users.noreply.github.com> Date: Tue, 19 Feb 2019 19:03:14 +0100 Subject: [PATCH] add deviceModel --- models/deviceModel.js | 53 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 models/deviceModel.js diff --git a/models/deviceModel.js b/models/deviceModel.js new file mode 100644 index 0000000..cbb7c32 --- /dev/null +++ b/models/deviceModel.js @@ -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); +};