mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Remove watchChangeStream method and its import from Mongo.Collection
This commit is contained in:
@@ -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 });
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user