dart_meteor icon indicating copy to clipboard operation
dart_meteor copied to clipboard

meteor.collection.listen wrong data

Open DeltaDivine opened this issue 1 year ago • 2 comments

hi @tanutapi , i test meteor.collection.listen but the data received from it is different than the actual data in the mongo database This is the publication in my backend meteor server:

import { Meteor } from 'meteor/meteor';
import { CallsCollection } from '/imports/db/CallsCollection';
Meteor.publish('calls', function () {
  console.log('trigger publish calls');
  return CallsCollection.find({ userId: this.userId });
});

This is my flutter code:

meteor.collection('calls').listen((data) {
      print('calls $data');
    });

The data in mongo database is for example:

{
  "_id": "iw4pvazPnp2qZqB2S",
  "roomId": "B5kTz49xD77YYLKnz",
  "roomName": "congvt-delta++congvt-delta6a6",
  "userId": "3aMt4yPpL3u52Y6Na",
  "updatedAt": {
    "$date": "2024-08-26T16:50:16.316Z"
  },
  "createdAt": {
    "$date": "2024-08-26T16:50:16.316Z"
  },
  "memberIds": [
    "3aMt4yPpL3u52Y6Na",
    "bfPcM57ZNbhqcfAvz"
  ],
  "caller": "bfPcM57ZNbhqcfAvz",
  "status": "init",
  "calleeIds": [
    "bfPcM57ZNbhqcfAvz"
  ]
}

But the data i received from listen is lacking some data in memberIds field or sometime just an empty list :

{
  "_id": "iw4pvazPnp2qZqB2S",
  "roomId": "B5kTz49xD77YYLKnz",
  "roomName": "congvt-delta++congvt-delta6a6",
  "userId": "3aMt4yPpL3u52Y6Na",
  "updatedAt": {
    "$date": "2024-08-26T16:50:16.316Z"
  },
  "createdAt": {
    "$date": "2024-08-26T16:50:16.316Z"
  },
  "memberIds": [
    "3aMt4yPpL3u52Y6Na",
  ],
  "caller": "bfPcM57ZNbhqcfAvz",
  "status": "init",
  "calleeIds": [
    "bfPcM57ZNbhqcfAvz"
  ]
}

Sorry for my bad english Thank you

DeltaDivine avatar Aug 26 '24 17:08 DeltaDivine

The memberIds should replicate your Mongo document on your server. You can enable the debugging by passing debug: true to the MeteorClient.connect(...)

By the way, what is your Meteor version?

tanutapi avatar Aug 27 '24 06:08 tanutapi

The memberIds should replicate your Mongo document on your server. You can enable the debugging by passing debug: true to the MeteorClient.connect(...)

By the way, what is your Meteor version?

My meteor server version is 2.16

DeltaDivine avatar Aug 27 '24 13:08 DeltaDivine