Level Up! MongoDB presentation slides

 

These are the slides from a 60-minute presentation I gave at CFCAMP in Munich, Germany on 15th October, 2013.

The blurb for the presentation was: “The new generation of NoSQL databases offer unprecedented flexibility and ease-of-use when compared to their more traditional, relational rivals. Discover how adding the powerful features of market-leading NoSQL database MongoDB to your skill set can make your ColdFusion development both more productive and more enjoyable.”

The presentation was made to a group of ColdFusion developers with little to no experience of MongoDB or any other NoSQL database.
After a brief introduction to MongoDB, the product and company, the emphasis was on the practicalities of using MongoDB to perform the everyday CRUD (Create, Retrieve, Update, Delete) operations.

A lot of these slides will not make much sense without the talk to go with them but there you go – it was a presentation not a book reading.

As may be apparent, I am a developer not a designer.

Level Up! at CFCAMP 2013

I shall be speaking at this years CFCAMP to be held in Germering near Munich, Germany on October 14th and 15th this year. The subject is MongoDB and ColdFusion. Here’s the blurb…

Level Up!
Taking your ColdFusion apps to the next level with MongoDB.

The new generation of NoSQL databases offer unprecedented flexibility and ease-of-use when compared to their more traditional, relational rivals.

Discover how adding the powerful features of market-leading NoSQL database MongoDB to your skill set can make your ColdFusion development both more productive and more enjoyable.

My talk is for those ColdFusion developers who just haven’t found the time to delve into exactly what NoSQL in general and MongoDB in particular are all about. A basic understanding of ColdFusion syntax will be useful but no MongoDB experience is necessary.

There are still some CFCAMP tickets available – as always, the sooner you book the less you’ll pay for this great event.

More:

jList 1.6.0: Eight new functions added

Earlier today I pushed jList 1.6.0 to GitHub. This version of the library, which brings ColdFusion-style list handling to Javascript, adds eight new functions, bringing the total to thirty:

  • listConcatenate
    Adds one list to the end of another.
  • listDifference
    Returns the elements that are unique to each of two different lists.
  • listIntersection
    Gets the elements that are common to each of two different lists.
  • listRemove
    Removes elements in one list from another list.
    Matching is case-sensitive.
  • listRemoveNoCase
    Removes elements in one list from another list.
    Matching is not case-sensitive.
  • listReplace
    Replaces any occurrences of an element in a list with a different element.
    Matching is case-sensitive.
  • listReplaceNoCase
    Replaces any occurrences of an element in a list with a different element.
    Matching is not case-sensitive.
  • listUnion
    Combines the elements from two different lists.

For the first time, these changes were not made by me but by Chris Tsongas. This was the first time Chris had contributed to an open source project and he did a great job of adding new functionality as well as making sure all of the tests and documentation were brought up-to-date.

All documentation is updated so full details of the new functionality is on the jList GitHub page.

All eight new functions have also been added to jsFiddle should you wish to try them out first –

listConcatenate

listDifference

listIntersection

listRemove

listRemoveNoCase

listReplace

listReplaceNoCase

listUnion

jList 1.6.o can be downloaded for free from GitHub.

More:

Previously:

jList 1.5.0: Two new functions added

Even though I wrote the original, rather messy, version of jList over five years ago I’ve never had the need for a listContains function i.e. one that searches a list looking for an item which at least partially matches a string. Until now, that is.

Yesterday I pushed jList 1.5.0 to GitHub. This version of the library, which brings ColdFusion-style list handling to Javascript, adds two new functions, bringing the total to twenty-two:

  • listContains
    Determines the index of the first list element that contains a specified substring.. The search is case-sensitive.
  • listContainsNoCase
    Determines the index of the first list element that contains a specified substring. The search is not case-sensitive.

These functions look at each individual element of a list for a specific value.  Where the value being searched for is wholly or partially contained within an element  then the position of that element in the list is returned. Where no match is found, zero is returned.

For example:


jList.listContains("cat,dog,mouse,rabbit,lion", "bit")

would return 4 even though the value itself is not in the list.

All documentation is updated so full details of the new functionality is on the jList GitHub page.

The two new functions have also been added to jsFiddle should you wish to try them out first – listContainslistContainsNoCase.

jList 1.5.o can be downloaded for free from GitHub.

More:

Previously:

jList 1.4.1: a bug fix for listFind

Today I checked version 1.4.1 of jList into GitHub. This release contains only one bug fix – to listFind.

The listFind function uses array.indexOf to search arrays, if it is available (it is in all modern browsers). Where it isn’t available (e.g. in Internet Explorer versions prior to 9) I fall back to using a less efficient for loop. Unfortunately there was a syntax error in the fallback version that has been there from release 1. Of course, this should have been detected in testing, especially now that am I am using a Jasmine-based test suite, but the fact that it wasn’t emphasises one of the limitations of automated web testing – if you don’t run your test suite in a very broad range of browsers you’re running the risk of certain parts of your code never being tested at all.

jList 1.4.1 can be downloaded for free from GitHub.

 

More:

 

Previously:

jList 1.4.0: more validation and a Jasmine test suite

Earlier today I checked version 1.4.0 of jList into GitHub. This version adds:

  • More validation of input parameters
    When I first wrote jList I made a decision that there would be only the minimum validation of input parameters. This was to keep the file size down and also because it was for use by developers who should no better than to miss mandatory parameters. With this release I’ve relented a little – missing parameters will now throw an error. I’m still undecided about adding further validation in future…
  • Compatibility with jsLint Edition 2012-08-23.
    A recent change to jsLint meant that my missing parameter checks:

    if (tyepeof paramname === "undefined")
    

    were being flagged as errors. As full jsLint compatibility is an important part of jList these have been amended to the more appropriate and acceptable:

    if (paramname === undefined)
    
  • Jasmine test suite.
    The most significant change for this release isn’t to the code itself – I have added a test suite that allows future changes to be regression tested with the minimum of effort. Written in Javascript using the Jasmine framework, there are 250 tests that validate the output of each function. This is the first time that I have used Jasmine so it took a bit longer than I anticipated to learn the framework (though it is very easy) and create the test suite. It’s not perfect (I’m sure that I will add more tests in future) but it’s a very good start towards ensuring consistency from one change to the next.

jList 1.4.0 can be downloaded for free from GitHub.

 

More:

 

Previously:

ColdFusion: How to get the number of rows affected by a query

I’ve used ColdFusion for a great many years, a substantial number of them with Microsoft SQL Server. Not surprisingly, I’ve built up a significant collection of code snippets that I frequently reuse. One of the handiest is the use of @@rowcount to retrieve the number of rows affected by an insert, update or delete query. This can useful if we need to check, say, that only one row was updated or that a row was deleted as expected. For example:

<cfquery name="myQuery" datasource="myDatasource">
    set nocount off
    update ...
    select @@rowcount as numberOfRowsUpdated
    setnocount on
</cfquery>

<cfif myQuery.numberOfRowsUpdated GT 1>
    throw an error ...
</cfif>

As you can see, the number of rows updated by this query will, in this case, be returned in the variable myQuery.numberOfRowsUpdated. Simple enough, and this has worked for as long as I can remember (certainly before the pre-MX days).

Today, however, I had to do the same thing for a query that may run against MySQL or Oracle databases. My first impulse was to look for the equivalents of @@rowcount – for MySQL this is ROW_COUNT() and for Oracle it’s SQL%ROWCOUNT. Again, it’s easy enough to write a single query with a simple condition that returns the appropriate dbms variable depending on which database we are querying but it feels like a clumsy hack. Luckily, the ColdFusion cfquery tag (from version 7 onwards) offers a more elegant approach – the result property.

In my experience, the result property of cfquery is rarely used, which is a pity as it offers us quite a few benefits that are not immediately obvious from the documentation. By adding this property to our update query like so:

<cfquery name="myQuery" datasource="myDatasource" 
                        result="myQueryResult">
    update ...
</cfquery>

a number of properties are returned to us in the structure myQueryResult. The property we’re interested in is recordcount. When the query is a select it is set to the number of rows returned (as it usually is). However, for insert, update or delete queries it is set to the number of rows affected by the query i.e. the number of rows inserted, updated or deleted. Testing this value is no more difficult than in the first example:

<cfif myQueryResult.recordcount GT 1>
    throw an error ...
</cfif>

Altogether a simpler, cleaner and more reliable cross-platform method of getting at this value.