Hugoware

The product of a web developer with a little too much caffeine

Posts Tagged ‘Release

jLinq Update (2.2.1)

with 10 comments

I’m off from work this week so the first thing I did was get some work done on jLinq. I’ve had a few bugs I’ve needed to sort out along with a new feature I wanted to implement. I’m also going to be working on documentation this week. Previously, I had created a Wiki and was hoping that people might add to the documentation… but instead spam bots pretty much ruined it so I’ll be starting over from scratch… oh well..

New Features

jLinq itself doesn’t really have a new feature but instead a new way to get the jLinq library. Instead of simply downloading a standard jLinq library you can use the new online jLinq Framework Generator to select only the functionality that you want to include. You can still download the basic pack but this option gives you a little more control what goes into your version of jLinq.

Changes

The most notable change for jLinq is that all of the operator commands have been included as standard functions for the framework. Before, these functions were actually methods extended onto the framework. Since these functions are required for jLinq to work I’ve moved them so that they are in every jLinq framework by default.

Bug Fixes

orderBy with joined records would return incorrect results
jLinq uses eval to figure out the values of field names since you can provide methods, array indexes or whatever. The code used to sort the values wasn’t getting the values correctly so the sorted result was always wrong.

using 0 in certain comparisons would return incorrect results
Ah, this one was fun. So check out the code below…

var values = [ 0 ];
var index = 0;
var a = !values[index];
var b = values[index] == null;

So what is a and what is b? If you said true and false then give yourself a cookie.

jLinq uses the number of arguments passed to help determine if anything is being memorized (like the field name). jLinq makes a quick pass to select all values until it finds a null value… or at least that is what I meant for it to do. Unfortunately, I wasn’t thinking when I wrote that method and didn’t check explicitly for null.

Feedback

If you find any problems with jLinq or have any suggestions, please leave a comment or contact me directly.

Written by hugoware

November 23, 2009 at 9:03 pm

Double Whammy – jLinq Release And Screencast!

with 2 comments

Now that you’re all excited time for some disappointment – it is just a minor update to fix a few bugs and to add one new feature.

But instead of just blogging about it I’ve also done a new screencast to talk about the updates and new feature in this release.

  • Dynamic Queries (using OR) – Before, if you used “OR” at the start of a query then you’d get an exception. jLinq would try and tag “||” at the start of your query which would cause the whole thing to collapse. Now, jLinq correctly handles this and prevents the error. In turn, writing dynamic queries just got a whole lot easier!.
  • Range Comparisons With Dates – Version 2.2.0 introduced smarter comparisons by evaluating the types of values being passed in instead of expecting only one type. However, in the change, the range comparisons like greater, less, between, etc, would all incorrectly evaluate Dates as strings… bummer.
  • Bitwise Flag Comparisons – jLinq 2.2.1 introduces a new query method called has which performs bitwise flag comparisons on records. It even works with regular ol’ numbers by converting them before performing the comparisons.

Anyways, go check out he new screen cast now and tell me what you think!


screencast-4-play

Bonus: CamStudio Icon

camStudioExample

Last night while I was setting up CamStudio for this screencast I was looking at their UGLY icon they use for their program — I just couldn’t stand it being in my beautiful RocketDock – so I designed a new one for them. If you’re looking for an improved logo then you can download the PNG for the CamStudio icon.

Written by hugoware

September 9, 2009 at 2:18 am

jLinq 2.2.0 Released!

with 14 comments

Ever hear of jLinq. If not, it’s no big deal. Its a personal project of mine to make a LINQ style query language for Javascript. With all these “Web 2.0” applications floating around, the ability to sort, query and manage your records on the client side may become a necessity. Use jLinq with the JSON data you already have and you’ve got quite a combination.

If you haven’t tried it out, there is an online version available you can use to see it in action.

Below are some of the new features in jLinq 2.2.0.

Smarter Comparisons

Let’s say you ran the command below…

jLinq.from(users)
    .less("firstname", 5)
    .select();

Seems simple enough, first names less than 5 characters long?

Nope…

The previous version of jLinq expected certain data types depending on the command. For example, if you used less, lessEquals, greater, greaterEquals, between or betweenEquals then the expected parameter was a number as was the field you were querying against.

In the new version you’ll find code like this when checking values.

//get the the parameter value
value = query.helper.when(value, {
number:function() { return value; },
other:function() { return value.length; }
});

//determine how to check this against the value
return query.when({
string:function() {
return (query.value.length < value); }, array:function() { return (query.value.length < value); }, other:function() { return (query.value < value); } }); [/sourcecode] Instead of making any assumptions, jLinq now checks the types and returns the values required to make the query work. For example, if you use 'less' with a string value, the length property is automatically used instead of the string value itself. jLinq also is more intelligent with different command types. For example, the .contains() used to work with string values only. Now it works with arrays or converts a value to a string then checks the result.

11 New Commands

  • attach(alias, function): Executes and attaches the return value of your function onto the record using the alias name you provice.
  • sum(field): Returns an object with information about the sum of the field name used.
    returns {
    count:the number of records counted,
    result:the sum of all records selected,
    records:the records used to find the sum
    }
  • average(field): Returns an object with information about the average of the field name used.
    returns {
    total:the sum before the average was calculated,
    count:the number of records used,
    result:the average of all records selected,
    records:the records used to find the average
    }
  • max(field): The maximum value found for the field name provided.
  • min(field): The minimum value found for the field name provided.
  • except(collection): Compares a second set of records and only returns records that are not found in the comparison list. Returns a new jLinq object. (example)
  • intersect(collection): Compares a second set of records and only returns records that are found in both lists. Returns a new jLinq object. (example)
  • union(collection): Compares a second set of records and only returns records that are unique in both lists. Returns a new jLinq object. (example)
  • skipWhile(delegate): Skips selecting records until the first ‘false’ result is returned from your function. After that point, all records are selected. Returns an array of results. (example)
  • takeWhile(delegate): Selects records until the first ‘false’ result is returned from your function. After that point, all records are ignored. Returns an array of results. (example)
  • selectMany(collection, compareFunction, selectionFunction): Compares each value of the current query against the provided collection array (example). For each successful comparison a new record is added to your results. If you use your own selection method then you need to write a function similar to function(queryRecord, compareRecord) {. The return value will be added to the list. If no selection method is used, then the following object is returned.
    returns {
    source:the record in the jLinq query that is compared,
    compare:the record in the collection array that is compared
    }

Bug Fixes

There was an Opera bug when you tried to sort records. I’m not sure that I understand why, but basically, there really is a difference between for loops in Opera.

jLinq Testing

If you’re interested in creating your own jLinq extension methods you can now download a series of tests that you can use to determine that your command doesn’t break anything else in jLinq.

Wrapping Up

Whew! You’re still with me? You must be dedicated!

Right now I realize that there still may be some confusion on how to use jLinq. I’m currently working on some screencasts that I can share to help people get started.

If you have some requests on what you would like to see in an upcoming screencast, please send me your ideas and I’ll add them to my list.

Source Code

Download jLinq-2.2.0.js

.

Written by hugoware

June 28, 2009 at 3:04 pm

jLinq 2.1.1 Released

with 2 comments

A newer version of jLinq is now available – jLinq 2.2.0

jLinq 2.1.1 has been released.

This version makes a fix to a very annoying IE bug that would cause arrays to be sorted reversed from all other browsers.

You most likely will want to update to this version to avoid any problems using jLinq.

Written by hugoware

May 14, 2009 at 3:02 am