Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
765 B
1
Indexable
Never
import { Schema, model } from "mongoose";
import uniqueValidator from "mongoose-unique-validator";
const billSchema = new Schema(
  {
    customer: { type: Number, required: true, uniqueValidator: true},    name: { type: String, required: true },
    lastname: { type: String, required: true },
    address: { type: String, required: true },
    phone: { type: Number, required: true },
    email: { type: String, required: true },
    item: { type: String, required: true },
    quantity: { type: Number, required: true },
    price: { type: Number, required: true },
    subtotal: { type: Number, required: true },
  },
  {
    versionKey: false,
  }
);

billSchema.plugin(uniqueValidator);
export default model("bill", billSchema, "bill");