Skip to content

Tag: node.js

Mongoose – What does the exec function do?

I came across a piece of Mongoose code that included a query findOne and then an exec() function. Ive never seen that method in Javascript before? What does it do exactly? Answer Basically when using mongoose, documents can be retrieved using helpers. Every model method that accepts query conditions can be ex…

Using Node.js require vs. ES6 import/export

In a project I am collaborating on, we have two choices on which module system we can use: Importing modules using require, and exporting using module.exports and exports.foo. Importing modules using ES6 import, and exporting using ES6 export Are there any performance benefits to using one over the other? Is …

How to automatically zip files with Node.js and npm

Is there a way to automatically zip certain files at the build time with Node.js and npm? For example, I have a project, that file structure looks like this: I want to be able to zip lib folder, certain modules from node_modules and index.js into some zip archive to upload it on the AWS Lambda, for example. I…

Parse XLSX with Node and create json

Ok so I found this really well documented node_module called js-xlsx Question: How can I parse an xlsx to output json? Here is what the excel sheet looks like: In the end the json should look like this: index.js: Answer Improved Version of “Josh Marinacci” answer , it will read beyond Z column (i.…