tanutapi / dart_meteor

A Meteor DDP library for Dart/Flutter developers.
Other
37 stars 15 forks source link

meteor.collection.listen wrong data #72

Open DeltaDivine opened 2 months ago

DeltaDivine commented 2 months ago

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

tanutapi commented 2 months ago

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?

DeltaDivine commented 2 months ago

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