| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- const isSanitary = require("../controllers/helper.js").isSanitary;
- const mongoose = require("mongoose");
- let emailValid = (value)=>{
- /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(value);
- }
- const MerchantSchema = new mongoose.Schema({
- name: {
- type: String,
- required: [true, "MERCHANT NAME IS REQUIRED"],
- validate: {
- validator: isSanitary,
- message: "NAME CONTAINS ILLEGAL CHARACTERS"
- }
- },
- email: {
- type: String,
- required: [true, "EMAIL IS REQUIRED"],
- validate: {
- validator: emailValid,
- message: "INVALID EMAIL ADDRESS"
- }
- },
- password: {
- type: String,
- required: [true, "MUST PROVIDE A PASSWORD"],
- },
- pos: {
- type: String,
- required: true
- },
- posId: String,
- posAccessToken: String,
- lastUpdatedTime: {
- type: String,
- default: Date.now()
- },
- createdAt: {
- type: Date,
- default: Date.now
- },
- status: [],
- squareLocation: String,
- inventory: [{
- ingredient: {
- type: mongoose.Schema.Types.ObjectId,
- ref: "Ingredient",
- required: [true, "MUST PROVIDE THE INGREDIENT"]
- },
- quantity: {
- type: Number,
- required: [true, "INGREDIENT QUANTITY IS REQUIRED"]
- },
- defaultUnit: {
- type: String,
- required: [true, "INGREDIENT UNIT IS REQUIRED"]
- }
- }],
- recipes: [{
- type: mongoose.Schema.Types.ObjectId,
- ref: "Recipe"
- }],
- verifyId: String
- });
- module.exports = mongoose.model("Merchant", MerchantSchema);
|