Not getting all collection values for sitemap.xml

I’m trying to generate a sitemap. I have a collection Quicks that contains about a handful of search shortcuts. Each of this Quicks is rendered as an URL in the sitemap.

For each quick I’d like to get the date of the last upload (to the collection EboyPix) — and use it as the lastmod property for the sitemap.

When iterating through Quicks the first two return undefined for the createdAt field. As if function getLatestQuickDate needed a bit of time to get going.

What can I do? This script sits on /server/sitemap.js


// Meteor stuff
import { sitemaps } from 'meteor/gadicohen:sitemaps';

// Collections
import { Quicks } from '../imports/api/quicks/quicks.js'; // search shortcuts
import { EboyPix } from '../imports/api/eboypix/eboypix.js';

// Returns the date of the last upload matching the slug
function getLatestQuickDate(slug) {
  const latestSlug = EboyPix.findOne(
    { tags: slug },
    { sort: { createdAt: -1, limit: 1 } }
  if (latestSlug) { // is undefined for for first two quicks 
    return latestSlug.createdAt;

// Return array of pages from Quicks collection
const quicksLabels = Quicks.find().fetch();
const quicksLinks = function() {
  let quicksPagesAll = [];
  if (quicksLabels) {
    Object.keys(quicksLabels).forEach(function(key) {
      const slug = quicksLabels[key].slug.toString();
      const lastmod = getLatestQuickDate(slug);
      const quicksPage = {
        page: 'pool/' + quicksLabels[key].label + '/1',
        changefreq: 'weekly',
        priority: quicksLabels[key].rank,
        lastmod: lastmod
    return quicksPagesAll;

sitemaps.add('/sitemap.xml', function() {
  return quicksLinks();

My fault, this is solved:

The first two items did not return anything as the function was searching in ‘tags’ (which returns 0 documents matching for ‘everything’ and ‘pixorama’).

The code itself seems to be fine. Sorry to waste anyone’s time.