Scaraux
Scaraux

Reputation: 4172

MongoDB schema : default coordinates for GPS position

What GPS coordinates should I insert to a newly created user document which hasn't uploaded his position yet ? For now, I am simply inserting 0 and 0, because inserting values like 'undefined', makes the DB throwing some errors...

Here is my schema :

var userSchema = new mongoose.Schema({
firstname: {
  type: String,
  required: true,
  unique: false
},
lastname: {
  type: String,
  required: true,
  unique: false
},
location: {
  'type': {
    type: String,
    required: true,
    enum: ['Point', 'LineString', 'Polygon'],
    default: 'Point'
  },
  coordinates: [Number],
  select: false
},

});

Upvotes: 2

Views: 711

Answers (1)

PeterVC
PeterVC

Reputation: 4604

You could use any magic value like 0,0 or you could use a location that is outside the scope/bounds of whatever it is your recording, like the peak of mount Everest, a volcanic creator, the south pole, etc.

Upvotes: 3

Related Questions