1

Just learning Cloudant NOSQL on Bluemix. I have been successful adding my weather data to the database, simple queries, and even pulling it out to a mobile app using Kinetise. I am not a SW developer,but I am an engineer.

I need to access the moment.js date math capability as I believe this will help me sum weather station data over the last 24hours, 7days, and 30d relative to the current moment in time. I though this would be easy not knowing any better. Clearly you need to saddle up when doing anything beyond the basic with Javascript dates/time.

I am trying to create a map that uses moment.js math capabilities and can't figure out how to include that library. I saw bits and pieces of 'lib' and 'require' necessity and just need help very exactly on how to do it. Reviewed CouchdB site as well and I just don't get it.

Community
  • 1
  • 1
DPGUITARMAN
  • 161
  • 1
  • 2
  • 12

1 Answers1

2

you may want to review/follow the instructions here:

http://www.swarmforest.com/blog/how-to-use-js-libs-like-underscorejs-in-your-couchdb-views/

there are also multiple answers here:

How do I DRY up my CouchDB views?

which may be worth reviewing.

Community
  • 1
  • 1
vabarbosa
  • 706
  • 1
  • 4
  • 9
  • From the first post I have to copy all the javascript for moment.js into my design document to use it with the REQUIRE keyword. Really? The DRY link indicates I can use the lib keyword within the design doc as so, `views: { lib: { underscore: "// Underscore.js 1.1.6\n ... } ... [ the rest of your views go here] }` This second method seems to indicate I can reference the library stored somewhere? If that is true, I just don't understand how to do it. – DPGUITARMAN Sep 21 '16 at 23:41
  • 1
    it is not possible to just include/reference an external library. in both above cases, you would need to copy the actual library code directly into the design doc – vabarbosa Sep 22 '16 at 15:25
  • Would the best practice in this instance be to copy the entire Moment.js into the design doc or to process outside the database. – DPGUITARMAN Sep 22 '16 at 22:16