Simple Meteor app just doesn't work anymore

Hi,

I have a little Meteor application as a pet project for autoformation. It used to work some versions ago. It doesn’t anymore. No errors. No traces. Nor server side, nor client side.

I have this simple code :smile:

imports/api/PlayersCollection.js

// External dependencies
import { Mongo } from "meteor/mongo";

export const PlayersCollection = new Mongo.Collection("players");

PlayersCollection.getOfficialRankings = () => {
    Log("Getting official rankings")
    let result = PlayersCollection.find(
        { rank: { $gt: 0 } },
        { sort: { elo: -1 }, limit: 200 }
      ).fetch();
    Log("officialRankings="+result);
    return result;
  }

imports/ui/App.svelte

<script>
    import MainTitle from './components/MainTitle.svelte';
    import Player from './components/Player.svelte';
    import {PlayersCollection} from '../api/PlayersCollection';

    $m : players = PlayersCollection.getOfficialRankings();
    Log("players ="+players);
    $m: sectionType = "byElo";
    
</script>


<div class="container">
    <MainTitle/>

    <div id="official">
        <table class="zigzag">
        <thead>
            <tr>
            <th class="header">#</th>
            <th class="header">Joueur</th>
            <th class="header">Rang</th>
            <th class="header">ELO</th>
            </tr>
        </thead>
        <tbody>
            {#each players as player, i}
                <Player rank={i+1} player={player} section={sectionType} />
            {/each}
        </tbody>
        </table>
    </div>

</div>

players is always empty.

There is a bot running server side using this PlayersCollection and it is working. The MongoDB connection seems ok.

Any clue ? It did work once with the same code !

I guess you need autopublish package.

The autopublish package is there. But I follow the idea and tried with publish/subscribe mechanism, same result. Collection is empty server side.

Have you tried running the equivalent find query on the meteor mongo CLI ? Maybe there are no records that match your criteria?

Another way you could debug is placing a debugger; line inside the getOfficialRankings function and running meteor with “–inspect”. Then you run the client and open the server side debug console in Chrome (so you get a chrome console attached to the server). Then you can play with your PlayersCollection and see exactly what your find statement is returning and what an empty find statement returns etc.

1 Like