@mac777/project-pinecone-models 1.1.25 → 1.1.26
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/dist/Event.js +4 -24
- package/package.json +1 -1
- package/src/Event.ts +4 -26
package/dist/Event.js
CHANGED
|
@@ -302,30 +302,10 @@ eventSchema.pre('save', async function (next) {
|
|
|
302
302
|
if (baseSlug.length > 50) {
|
|
303
303
|
baseSlug = baseSlug.substring(0, 50).replace(/-+$/, ''); // Remove trailing hyphen after truncation
|
|
304
304
|
}
|
|
305
|
-
//
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
// Check uniqueness and add counter if needed
|
|
310
|
-
while (!isUnique && counter < 100) {
|
|
311
|
-
const existingEvent = await mongoose_1.default.models.Event.findOne({
|
|
312
|
-
slug: slug,
|
|
313
|
-
_id: { $ne: this._id }
|
|
314
|
-
});
|
|
315
|
-
if (!existingEvent) {
|
|
316
|
-
isUnique = true;
|
|
317
|
-
}
|
|
318
|
-
else {
|
|
319
|
-
// Add counter suffix for uniqueness
|
|
320
|
-
slug = `${baseSlug}-${counter}`;
|
|
321
|
-
counter++;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
// Fallback: if still not unique after 100 attempts, add random suffix
|
|
325
|
-
if (!isUnique) {
|
|
326
|
-
const randomSuffix = Math.random().toString(36).substring(2, 8);
|
|
327
|
-
slug = `${baseSlug}-${randomSuffix}`;
|
|
328
|
-
}
|
|
305
|
+
// Use last 6 characters of event ID for uniqueness
|
|
306
|
+
// This ensures uniqueness without database queries
|
|
307
|
+
const idSuffix = this._id.toString().slice(-6);
|
|
308
|
+
const slug = `${baseSlug}-${idSuffix}`;
|
|
329
309
|
this.slug = slug;
|
|
330
310
|
}
|
|
331
311
|
}
|
package/package.json
CHANGED
package/src/Event.ts
CHANGED
|
@@ -394,32 +394,10 @@ eventSchema.pre('save', async function(next) {
|
|
|
394
394
|
baseSlug = baseSlug.substring(0, 50).replace(/-+$/, ''); // Remove trailing hyphen after truncation
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
//
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
// Check uniqueness and add counter if needed
|
|
403
|
-
while (!isUnique && counter < 100) {
|
|
404
|
-
const existingEvent = await mongoose.models.Event.findOne({
|
|
405
|
-
slug: slug,
|
|
406
|
-
_id: { $ne: this._id }
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
if (!existingEvent) {
|
|
410
|
-
isUnique = true;
|
|
411
|
-
} else {
|
|
412
|
-
// Add counter suffix for uniqueness
|
|
413
|
-
slug = `${baseSlug}-${counter}`;
|
|
414
|
-
counter++;
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// Fallback: if still not unique after 100 attempts, add random suffix
|
|
419
|
-
if (!isUnique) {
|
|
420
|
-
const randomSuffix = Math.random().toString(36).substring(2, 8);
|
|
421
|
-
slug = `${baseSlug}-${randomSuffix}`;
|
|
422
|
-
}
|
|
397
|
+
// Use last 6 characters of event ID for uniqueness
|
|
398
|
+
// This ensures uniqueness without database queries
|
|
399
|
+
const idSuffix = this._id.toString().slice(-6);
|
|
400
|
+
const slug = `${baseSlug}-${idSuffix}`;
|
|
423
401
|
|
|
424
402
|
this.slug = slug;
|
|
425
403
|
}
|