Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mongoose = require('mongoose');
- const GeoData = require('./geodata');
- const UserSchema = new mongoose.Schema({
- name: {
- type: String,
- required: true
- },
- createdAt: {
- type: Date,
- default: Date.now()
- },
- geodata: GeoData
- });
- UserSchema.index({ deviceToken: 1 }, { unique: true });
- module.exports = UserSchema;
- const mongoose = require('mongoose');
- const c2p = require('circle-to-polygon');
- const GeoDataSchema = new mongoose.Schema({
- location: {
- coordinates: [Number],
- type: {
- type: String
- }
- },
- createdAt: {
- type: Date,
- default: Date.now()
- },
- expireAt: {
- type: Date,
- default: new Date().setHours(12,0,0,0)
- }
- });
- GeoDataSchema.index({ location: "2dsphere", bounds: "2dsphere" });
- GeoDataSchema.index({ 'expireAt': 1 }, { expireAfterSeconds: 0 });
- module.exports = GeoDataSchema;
Add Comment
Please, Sign In to add comment