47 lines
825 B
JavaScript
47 lines
825 B
JavaScript
import { model, Schema, Types } from "mongoose";
|
|
import { locationSchema } from "../../helpers";
|
|
|
|
const schema = new Schema({
|
|
name: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
createdBy: {
|
|
type: Types.ObjectId,
|
|
required: true,
|
|
ref: "user",
|
|
},
|
|
createdOn: {
|
|
type: Date,
|
|
required: true,
|
|
},
|
|
location: locationSchema,
|
|
category: {
|
|
type: String,
|
|
required: true,
|
|
default: "OWN",
|
|
enum: ["OWN", "PARTNER", "VENDOR", "CLIENT", "DISTRIBUTOR"],
|
|
},
|
|
type: {
|
|
type: String,
|
|
required: true,
|
|
enum: [
|
|
"HQ",
|
|
"BRANCH",
|
|
"WAREHOUSE",
|
|
"VENDOR",
|
|
"PARTNER",
|
|
"DISTRIBUTOR",
|
|
"CLIENT",
|
|
],
|
|
},
|
|
entity: {
|
|
type: Types.ObjectId,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
schema.index({ location: "2dsphere" });
|
|
|
|
export default model("venue", schema);
|