Skip to content

Instantly share code, notes, and snippets.

@paulobunga
Last active December 18, 2019 00:47
Show Gist options
  • Save paulobunga/de8fd32e29d5936db3c7a6a8c0fe77e5 to your computer and use it in GitHub Desktop.
Save paulobunga/de8fd32e29d5936db3c7a6a8c0fe77e5 to your computer and use it in GitHub Desktop.
Product Model
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ProductSchema = new Schema({
name: { type: String, required: 'Name is required' },
sale_price: { type: Number, required: 'Sale price is required' },
cost_price: { type: Number, required: 'Cost price is required '},
quantity: { type: Number, default: 0 }
}, {
timestamps: true
});
module.exports = mongoose.model('Product', ProductSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment