aboutsummaryrefslogtreecommitdiff
path: root/web/models/mockpoints.js
blob: 05e9f1876daf0e516aec5ab7afb40e491235aecf (plain)
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
34
35
var mongoose = require('mongoose');

// Mongoose Schema definition
var Schema = mongoose.Schema;
var dumbJsonSchema = new Schema({
  type: String,
  coordinates: Array,
  gender: String,
  age: String,
  race: String,
  longhair: Boolean,
  longbeard: Boolean,
  extra: String,
  status: String
});

// Mongoose Model definition
var dumbJson = mongoose.model('dumbJstring', dumbJsonSchema, 'dumbpointscollection');

// this function gets ALL the points from the db
// returns the entire document without modifications
exports.get_points = function(callback) {
  dumbJson.find({}).exec(function(err, docs) {
    if (err) callback(err, null);
    callback(null, docs);
  });
}

// this function stores A user report into the db
exports.save_request = function(data, callback) {
  dumbJson.create(data, function(err, result) {
    if (err) callback(err, null);
    callback(null, result);
  });
}