Skip to content

Commit

Permalink
Add secondary index for models
Browse files Browse the repository at this point in the history
  • Loading branch information
megastary committed Mar 27, 2024
1 parent 0899d6f commit f856f23
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions models/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ var schema = new Schema({
name: {
type: String,
required: true,
index: true,
unique: true,
},
color: {
Expand All @@ -14,6 +15,7 @@ var schema = new Schema({
disabled: {
type: Boolean,
default: false,
index: true,
},
});

Expand Down
4 changes: 4 additions & 0 deletions models/delivery.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ var schema = new Schema({
supplierId: {
type: Schema.Types.ObjectId,
ref: "User",
index: true,
required: true,
},
productId: {
type: Schema.Types.ObjectId,
ref: "Product",
index: true,
required: true,
},
created_on: {
type: Date,
default: Date.now,
index: true,
},
amount_supplied: {
type: Number,
Expand All @@ -24,6 +27,7 @@ var schema = new Schema({
type: Number,
required: true,
min: 0,
index: true,
},
price: {
type: Number,
Expand Down
2 changes: 2 additions & 0 deletions models/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ var schema = new Schema({
type: Schema.Types.ObjectId,
ref: "User",
required: true,
index: true,
},
supplierId: {
type: Schema.Types.ObjectId,
ref: "User",
required: true,
index: true,
},
ordersId: [
{
Expand Down
3 changes: 3 additions & 0 deletions models/order.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ var schema = new Schema({
type: Schema.Types.ObjectId,
ref: "User",
required: true,
index: true,
},
deliveryId: {
type: Schema.Types.ObjectId,
ref: "Delivery",
required: true,
index: true,
},
order_date: {
type: Date,
Expand All @@ -18,6 +20,7 @@ var schema = new Schema({
invoice: {
type: Boolean,
default: false,
index: true,
},
invoiceId: {
type: Schema.Types.ObjectId,
Expand Down

0 comments on commit f856f23

Please sign in to comment.