Lodash in a CouchDB view

Could not make it work as-is, had to remove the new Function statement.

Had this logging to try to determine if any root object was available:

var _log_statements = [
  freeGlobal,
  freeSelf,
  freeExports,
  freeModule,
  module,
  module.id,
  'module.parent',
  module.parent,
  'module.isFinite',
  module.isFinite,
  'module.parent.isFinite',
  module.parent.isFinite
];
log('[LODASH] ' + _log_statements.join('; '));

And the results:

[info] 2017-11-18T04:14:57.265125Z nonode@nohost <0.7563.0> -------- OS Process #Port<0.8441> Log :: [reading_time] starting
[info] 2017-11-18T04:14:57.266086Z nonode@nohost <0.7561.0> -------- OS Process #Port<0.8439> Log :: function raised exception ["error", "compilation_error", "Module require('views/lib/lodash') raised error (new Error(\"call to Function() blocked by CSP\", \"views/lib/lodash\", 68))"] with doc._id 52ab5e447608d450b470f681090004e8
[info] 2017-11-18T04:14:57.267291Z nonode@nohost <0.7561.0> -------- OS Process #Port<0.8439> Log :: function raised exception (new ReferenceError("_ is not defined", "undefined", 9)) with doc._id d96348985360e1acd300206bde000a85
[info] 2017-11-18T04:14:57.267965Z nonode@nohost <0.7561.0> -------- OS Process #Port<0.8439> Log :: [reading_time] starting
[info] 2017-11-18T04:14:57.270286Z nonode@nohost <0.7563.0> -------- OS Process #Port<0.8441> Log :: function raised exception ["error", "compilation_error", "Module require('views/lib/lodash') raised error (new Error(\"call to Function() blocked by CSP\", \"views/lib/lodash\", 68))"] with doc._id 52ab5e447608d450b470f68109000edf
[info] 2017-11-18T04:14:57.271645Z nonode@nohost <0.7563.0> -------- OS Process #Port<0.8441> Log :: function raised exception (new ReferenceError("_ is not defined", "undefined", 9)) with doc._id 52ab5e447608d450b470f68109000534
[info] 2017-11-18T04:14:57.271988Z nonode@nohost <0.7563.0> -------- OS Process #Port<0.8441> Log :: [reading_time] starting
[info] 2017-11-18T04:14:57.285743Z nonode@nohost <0.7561.0> -------- OS Process #Port<0.8439> Log :: function raised exception (new TypeError("_.sortBy is not a function", "undefined", 19)) with doc._id d96348985360e1acd300206bde000a85
[info] 2017-11-18T04:14:57.286718Z nonode@nohost <0.7561.0> -------- OS Process #Port<0.8439> Log :: function raised exception (new ReferenceError("_ is not defined", "undefined", 9)) with doc._id 52ab5e447608d450b470f68109001a1e
[info] 2017-11-18T04:14:57.287033Z nonode@nohost <0.7561.0> -------- OS Process #Port<0.8439> Log :: [reading_time] starting
[info] 2017-11-18T04:14:57.287124Z nonode@nohost <0.7561.0> -------- OS Process #Port<0.8439> Log :: function raised exception (new TypeError("_.sortBy is not a function", "undefined", 19)) with doc._id 52ab5e447608d450b470f68109001a1e
[info] 2017-11-18T04:14:57.289165Z nonode@nohost <0.18178.0> -------- Index update finished for db: shards/c0000000-dfffffff/simpleshelf-dev-personal.1506479735 idx: _design/simpleshelfmobile
[info] 2017-11-18T04:14:57.296872Z nonode@nohost <0.7563.0> -------- OS Process #Port<0.8441> Log :: function raised exception (new TypeError("_.sortBy is not a function", "undefined", 19)) with doc._id 52ab5e447608d450b470f68109000534
[info] 2017-11-18T04:14:57.297591Z nonode@nohost <0.7563.0> -------- OS Process #Port<0.8441> Log :: [reading_time] starting
[info] 2017-11-18T04:14:57.298876Z nonode@nohost <0.18194.0> -------- Index update finished for db: shards/20000000-3fffffff/simpleshelf-dev-personal.1506479735 idx: _design/simpleshelfmobile
[notice] 2017-11-18T04:14:57.302086Z nonode@nohost <0.18041.0> 5965f563a1 localhost:5984 172.17.0.1 aji GET /simpleshelf-dev-personal/_design/simpleshelfmobile/_view/reading_time?include_docs=true&limit=21&reduce=false&skip=0 200 ok 387

Written by Andrew Ittner in public on Wed 22 November 2017. Tags: simpleshelf, lodash, couchdb, programming