Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9037785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:19:36+00:00 2026-06-16T09:19:36+00:00

I have a collection published on the server and auto-subscribed on the client. I’d

  • 0

I have a collection published on the server and auto-subscribed on the client. I’d like to set the ‘selected’ item on the session and have the template update to display only the selected item, but it seems this can only be done with a roundtrip to the server (which is totally unnecessary).

Common:

var Missions = new Meteor.Collection('missions');

Client:

Template.missionList.missions = function() {
    var currMission = Session.get('selectedMission');
    var searchMission = {};
    if(currMission)
    {
        searchMission['_id'] = currMission;
    }
    return Missions.find(searchMission);
};
Template.missionList.events({
    'click div.mission': function (e, t) {
        Session.set('selectedMission', 
            this._id == Session.get('selectedMission') ? null : this._id
        );
    }
});
Template.mission.isSelected = function() {
    return this._id == Session.get('selectedMission');
};
Meteor.autosubscribe(function () {
    Meteor.subscribe("missions");
});

Server:

Meteor.publish('missions', function() {
    // there are really some filters here, but removed for simplicity
    return Missions.find(); 
});

Template:

<template name="missionList">
    <div class="missionList">
    {{#each missions}}
        {{> mission}}
    {{/each}}
    </div>
</template>

<template name="mission">
    <div class="mission{{#if isSelected}} selected{{/if}}">details</div>
</template>

My requirement is for the Missions.find() in Template.missionList.missions to filter the client-side cached results, rather than to re-request from the server, but I can’t seem to find a flag or settings to allow me to tell minimongo to only use the currently available data.

I’m also not entirely sure if this is what I should be doing, I started out just using jQuery to hide the non-selected missions but getting my head round Meteor and it seems a natural fit to use the data and reactivity to drive selection/local-filtering.

Is there any way the roundtrip can be avoided or am I just using it wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T09:19:38+00:00Added an answer on June 16, 2026 at 9:19 am

    By setting up a publish / subscribe relationship, you are creating a simplified form of database replication. Minimongo will have a copy of the data locally and execute the find() locally without a server roundtrip. If you are seeing network activity or calls to the server code, it is because meteor is regularly working behind the scenes to keep the subscription in sync with the server, not for your specific find.

    This also means you have to wary of sending too much data to the client, so your server side publish function may want to filter by the specific fields needed by client, in addition to existing your selection criteria.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Collection List<Car> . How to compare each item from this collection with
I'm planning to have collection of items stored in a TCollection. Each item will
for example I have collection foo of documents like that: {tag_cloud:[{value:games, count:10}, {value:girls, count:500}]}
Q: I have a web application which published on a server .When i try
I have a SQL Server 2005 box set up for merge replication to SQL
first I have checked that Server Authentication is already set to: SQL server and
I have an ASP.NET c# web application published to a server of ours. It
Lets say I have collection of documents with specified longitude and latitude. type is
I have Class and Student objects. Both have collection of another as property. Which
We have a collection of entities of type called Unit , collection of entities

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.