Guest User

Untitled

a guest
Jun 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. const mongoose = require('mongoose');
  2. const GeoData = require('./geodata');
  3.  
  4. const UserSchema = new mongoose.Schema({
  5. name: {
  6. type: String,
  7. required: true
  8. },
  9. createdAt: {
  10. type: Date,
  11. default: Date.now()
  12. },
  13. geodata: GeoData
  14. });
  15.  
  16. UserSchema.index({ deviceToken: 1 }, { unique: true });
  17.  
  18. module.exports = UserSchema;
  19.  
  20. const mongoose = require('mongoose');
  21. const c2p = require('circle-to-polygon');
  22.  
  23. const GeoDataSchema = new mongoose.Schema({
  24. location: {
  25. coordinates: [Number],
  26. type: {
  27. type: String
  28. }
  29. },
  30. createdAt: {
  31. type: Date,
  32. default: Date.now()
  33. },
  34. expireAt: {
  35. type: Date,
  36. default: new Date().setHours(12,0,0,0)
  37. }
  38. });
  39.  
  40. GeoDataSchema.index({ location: "2dsphere", bounds: "2dsphere" });
  41. GeoDataSchema.index({ 'expireAt': 1 }, { expireAfterSeconds: 0 });
  42.  
  43. module.exports = GeoDataSchema;
Add Comment
Please, Sign In to add comment