Esempio n. 1
0
    def post(self):
        data = SensorRegister.parser.parse_args()

        sensor_data = SensorModel(data["sensor_id"], data["moisture"],
                                  data["temperature"])
        try:
            sensor_data.save_to_mongo()
        except:
            return {"message": "Database f****d up"}, 400

        return sensor_data.jsonify()
Esempio n. 2
0
from models.sensor import SensorModel
from database import Database

Database.initialize()
sensor1 = SensorModel(101, 100, 100)
sensor1.save_to_mongo()

for i in Database.find("sensor_trial", {"id": 101}):
    print(i)