Remove watchChangeStream method and its import from Mongo.Collection

This commit is contained in:
italo jose
2025-07-18 17:49:38 -03:00
parent e7d0884324
commit 3301963905
2 changed files with 0 additions and 35 deletions

View File

@@ -11,7 +11,6 @@ import {
validateCollectionName
} from './collection_utils';
import { ReplicationMethods } from './methods_replication';
import { watchChangeStream } from './watch_change_stream';
/**
* @summary Namespace for MongoDB-related items
@@ -268,6 +267,3 @@ Meteor.Collection = Mongo.Collection;
// Allow deny stuff is now in the allow-deny package
Object.assign(Mongo.Collection.prototype, AllowDeny.CollectionPrototype);
// Só agora que Mongo.Collection existe, adicionamos o método ao prototype
Object.assign(Mongo.Collection.prototype, { watchChangeStream });

View File

@@ -1,31 +0,0 @@
/**
* @summary Watches the MongoDB collection using Change Streams.
* @locus Server
* @memberof Mongo.Collection
* @instance
* @param {Array} [pipeline] Optional aggregation pipeline to filter Change Stream events.
* @param {Object} [options] Optional settings for the Change Stream.
* @returns {ChangeStream} The MongoDB ChangeStream instance.
* @throws {Error} If called on a client/minimongo collection.
*
* @example
* const changeStream = MyCollection.watchChangeStream([
* { $match: { 'operationType': 'insert' } }
* ]);
* changeStream.on('change', (change) => {
* console.log('Change detected:', change);
* });
*/
export function watchChangeStream(pipeline = [], options = {}) {
// Only available on server
if (typeof Package === 'undefined' || !this.rawCollection) {
throw new Error('watchChangeStream is only available on server collections');
}
const raw = this.rawCollection();
if (!raw.watch) {
throw new Error('Underlying collection does not support watch (Change Streams)');
}
console.log('[watchChangeStream] Chamando raw.watch() com pipeline:', JSON.stringify(pipeline, null, 2), 'e options:', JSON.stringify(options, null, 2));
return raw.watch(pipeline, options);
}