Merge pull request #6 from kfnawaz/Feat-Item-association-model
Feat- Item association model
This commit is contained in:
27
src/models/ItemAssociation.js
Normal file
27
src/models/ItemAssociation.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const mongoose = require("mongoose");
|
||||
|
||||
const schema = new mongoose.Schema(
|
||||
{
|
||||
item_id: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: "Item",
|
||||
},
|
||||
sub_level_id: {
|
||||
type: mongoose.Schema.Types.ObjectId,
|
||||
ref: "Sublevel",
|
||||
},
|
||||
quantity: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
);
|
||||
|
||||
schema.index({ item_id: 1, sub_level_id: 1 }, { unique: 1 });
|
||||
|
||||
const ItemAssociation = mongoose.model("ItemAssociation", schema);
|
||||
|
||||
module.exports = ItemAssociation;
|
||||
Reference in New Issue
Block a user