LOGIN
Robert Lancer
51
Community Expert
Chief Technology Officer at Collaborizm (Project Leader)
 · New YorkU.S.
Share
Report
Get Link
STORY

Generating site maps using es6 template strings.

    r.db("collab").table("discussions").orderBy({index: r.desc('touchRank')}).pluck('id', 'touchRank', 'createdOn', 'lastReplyOn').run().then(results=> {
      res.send(`<?xml version="1.0" encoding="UTF-8"?>
        <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        ${results.map(row=> {
          const {id, lastReplyOn, createdOn} = row;
          if (lastReplyOn || createdOn)
            return `<url>
                <loc>${config.basepath}/thread/${id}</loc>
                <lastmod>${(lastReplyOn || createdOn).toISOString()}</lastmod>
                <changefreq>weekly</changefreq>
                <priority>0.5</priority>
              </url>`;
          else
            return '';
        }).join('')}</urlset>`
      );
    })

Javascript #RethinkDB

Javascript
2 likes 
Like
Award Contribution
Leave a reply...
DISCOVER
CHAT
HIRE
ACTIVITY
FEED
New Post
Help
Start Project
Online Users
Share Link
Write something before you submit it!
Photo updated
Request Sent!
Updated
Copied to Clipboard