@grapadigital/shared-schemas 1.0.192 → 1.0.193

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.
@@ -165,7 +165,11 @@ Comment = __decorate([
165
165
  ], Comment);
166
166
  exports.Comment = Comment;
167
167
  exports.CommentSchema = mongoose_1.SchemaFactory.createForClass(Comment);
168
- exports.CommentSchema.index({ content: 1, externalId: 1 }, { unique: true, partialFilterExpression: { sourceCommentId: { $exists: false } } });
168
+ // partialFilterExpression não aceita $exists:false (só $exists:true) usamos
169
+ // igualdade com null, que no Mongo casa tanto "campo ausente" quanto "campo
170
+ // null" (cobre o documento original, sem exigir que quem insere via
171
+ // bulkWrite raw declare sourceCommentId explicitamente).
172
+ exports.CommentSchema.index({ content: 1, externalId: 1 }, { unique: true, partialFilterExpression: { sourceCommentId: null } });
169
173
  exports.CommentSchema.index({ action: 1, funnel: 1 });
170
174
  exports.CommentSchema.index({ action: 1, target: 1 });
171
175
  exports.CommentSchema.index({ content: 1, parent: 1 });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grapadigital/shared-schemas",
3
- "version": "1.0.192",
3
+ "version": "1.0.193",
4
4
  "description": "Shared Mongoose Schemas",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -143,9 +143,13 @@ export class Comment {
143
143
 
144
144
  export const CommentSchema = SchemaFactory.createForClass(Comment);
145
145
 
146
+ // partialFilterExpression não aceita $exists:false (só $exists:true) — usamos
147
+ // igualdade com null, que no Mongo casa tanto "campo ausente" quanto "campo
148
+ // null" (cobre o documento original, sem exigir que quem insere via
149
+ // bulkWrite raw declare sourceCommentId explicitamente).
146
150
  CommentSchema.index(
147
151
  { content: 1, externalId: 1 },
148
- { unique: true, partialFilterExpression: { sourceCommentId: { $exists: false } } },
152
+ { unique: true, partialFilterExpression: { sourceCommentId: null } },
149
153
  );
150
154
  CommentSchema.index({ action: 1, funnel: 1 });
151
155
  CommentSchema.index({ action: 1, target: 1 });