Hugoware

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

jLinq Screencast #3 – Modifying Records During A Query

with 3 comments

Sometimes when you get your records they aren’t exactly what you we’re needing, or sometimes some of the fields need to be formatted before they can be queried against. Fortunately, jLinq comes with that functionality built into it.

This screencast goes over several of the methods you have available to you that allow records to be formatted before they are selected.

  • each(delegate(record)): Performs a loop through each of the values in the array. This code can be used to modify records, create new properties or anything you need it to do.
  • attach(alias, delegate(record)): Performs the method passed in on each of the records in the array and attaches the result to the record using the alias provided.
  • join(records, alias, foreignKey, primaryKey): Joins two arrays together using the alias and the keys to match the values. Joins tend to be slow when using large arrays, so use caution.


screencast3

If you have any recommendations or requests for the next screencast, please let me know and I’ll see what I can do.

Side note: Never improvise on a screen cast – nothing like having to redo a screen cast twice because you say something that isn’t true and then realize it while recording. 🙂

Advertisements

Written by hugoware

August 24, 2009 at 2:21 am

3 Responses

Subscribe to comments with RSS.

  1. Good stuff! I’m using jLinq on a project now and it has saved me TONS of time. One of the factors that I use when selecting tools / libs / frameworks is that the tool should not take me too far out of my flow. That is, many times I’m in the thick of things and need a solution where I don’t have to shift gears in order to get things working.

    This makes jLinq an attractive tool for .Net devs. I think one of the obstacles that some people have with the client side / jQuery realm is that Javascript, closures, the $ signarture, CSS and selectors are different from Visual Studio. jLinq really does a good job at helping you bridge the gap in that I can rely on my familiarity with Linq to get data client side.

    On a tangential note, have you looked at “ActiveRecordJS? It’s a Javascript implementation of ActiveRecord by the Aptana folks. I haven’t used it yet but it looks promising.

    Love jLinq dude. Keep it up!

    ActiveEngine Sensei

    August 25, 2009 at 6:07 am

    • Thanks man, glad it is helping you out.

      I did a search for ‘ActiveRecordJS’ and ended up coming across this explanation. After very cursory read over the page it left me wondering is it a client side solution? an interface to the server side? both?? 🙂

      In any case, it sounds like I could learn from stuff from them – I’ll definitely read into this some more. Thanks for the info.

      webdev_hb

      August 25, 2009 at 8:40 am

  2. From my reading that while it is an implmentation of ActiveRecord, you can create in memory objects and perform the same operations like Finds, gets, sets, etc. the same way that you would for the MySql / SQLLite stuff.

    I haven’t found anything for MS SQL Server and since this is my primary DB platform I haven’t found a opportunity to put it to use. One of my team members wants to use the Jaxer platform from Aptana and we might have a chance then to use it then.

    ActiveEngine Sensei

    August 26, 2009 at 5:53 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: