@francesco_ksh/app-ksh-mgd-schemas 1.6.4 → 1.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/models/Listing.js CHANGED
@@ -417,6 +417,7 @@ const listingSchema = new Schema(
417
417
  listingSchema.index({ '$**': 'text' });
418
418
  listingSchema.index({ author: 1 });
419
419
  listingSchema.index({ region: 1 });
420
+ listingSchema.index({ date: -1 });
420
421
  listingSchema.index({ status: 1 });
421
422
  listingSchema.index({ kashewId: 1 }, { unique: true, sparse: true });
422
423
 
package/models/Order.js CHANGED
@@ -524,10 +524,11 @@ orderSchema.pre('save', async function (next) {
524
524
  const lastOrder = await mongoose
525
525
  .model('Order')
526
526
  .findOne({})
527
- .sort({ kashewId: -1 })
527
+ .sort({ date: -1 })
528
+ .select('kashewId')
528
529
  .exec();
529
530
 
530
- let newId = 1; // Start from 1 if no orders exist
531
+ let newId = 10000; // Start from 10000 if no orders exist
531
532
  if (lastOrder && lastOrder.kashewId) {
532
533
  const lastIdNumber = parseInt(lastOrder.kashewId.slice(3), 10); // Remove "KSH" and parse the digits
533
534
  newId = lastIdNumber + 1;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@francesco_ksh/app-ksh-mgd-schemas",
3
- "version": "1.6.4",
3
+ "version": "1.6.6",
4
4
  "description": "Mongoose schema definitions",
5
5
  "main": "index.js",
6
6
  "repository": {