location controller updated with heading and created new models and controllers for remaining modules
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
import { model, Schema, Types } from "mongoose";
|
||||
import { locationSchema } from "../../helpers";
|
||||
|
||||
const geofenceSchema = new Schema({
|
||||
venue: {
|
||||
type: Types.ObjectId,
|
||||
required: false,
|
||||
ref: "venue",
|
||||
},
|
||||
action: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
});
|
||||
|
||||
const schema = new Schema({
|
||||
user: {
|
||||
type: Types.ObjectId,
|
||||
@@ -16,10 +28,21 @@ const schema = new Schema({
|
||||
type: Number,
|
||||
required: true,
|
||||
},
|
||||
venue: {
|
||||
type: Types.ObjectId,
|
||||
event: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
activity: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
heading: {
|
||||
type: Number,
|
||||
required: false,
|
||||
},
|
||||
geofence: {
|
||||
type: geofenceSchema,
|
||||
required: false,
|
||||
ref: "venue",
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -17,12 +17,13 @@ export const getLocationById = async (id) => {
|
||||
};
|
||||
|
||||
// Read (Get by Query)
|
||||
export const getLocationByQuery = async (query) => {
|
||||
return await Model.findOne(query).sort({ createdOn: -1 });
|
||||
export const getLocationsByQuery = async (query) => {
|
||||
console.log("QUERY", query);
|
||||
return await Model.find(query).sort({ createdOn: -1 });
|
||||
};
|
||||
|
||||
// Read (Get by Radius)
|
||||
export const getLocationByRadius = async (radius) => {
|
||||
export const getLocationsByRadius = async (radius) => {
|
||||
return await Model.find(query);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user