Working with File Storage and LoopBack

Update for March, 2017: One of the things I mention at the very end of this article is how file uploads will overwrite each other if they use the same name. I fixed this with a pull request that was accepted a few days ago. By using a new configuration option, nameConflict:makeUnique, files will automatically be renamed with a UUID and their original extension. I recommend *always* using this option!

I’ve got a confession to make: I absolutely love LoopBack. How much do I love it? Before I even joined the StrongLoop team at IBM I was blogging on LoopBack and giving presentations on it as well. I basically told the person interviewing me that it didn’t really matter if they hired me or not; I was going to evangelize LoopBack because I thought it was the coolest thing since sliced bread and beer. In general, I love LoopBack and every aspect of it. However, it doesn’t mean that it is perfect. Today I’m going to discuss a feature that is—in my opinion—somewhat “rough”. I’m not saying to avoid it, not at all, just be prepared for a somewhat bumpy ride. Ready?

So, one of the things that LoopBack makes incredibly easy is handling data in a persistence system. You define a model, let’s say Cat, various properties and types, and then LoopBack can handle persisting that in a variety of different storage mechanisms, from Oracle to MySQL to MongoDB. It just plain works, which is cool. However, the data we’re typically dealing with are simple strings represented in JSON. What about binary data?
Read more

Systematic Function Design in JavaScript

Habits can be damning or liberating. Perhaps you are like me. I know having tests, examples, and documentation are good things for any program but why do they always seem to be an afterthought? Wouldn’t it be great to have a coding methodology that propels me to write well-documented and tested programs that are easy to change? Thankfully, a team of professors/researchers have tackled this very problem and distilled their insights in what is called systematic program design or the HtDP methodology (How to Design Programs).

Why would you want to learn the HtDP methodology? HtDP gives you a process for designing functions, data, and worlds that driven by documentation, example, and tests. Well-designed HtDP programs are clear, tested, and easy to change. In this three-part series, we will look at some core concepts of HtDP as they apply to JavaScript: Read more