Thursday, July 21, 2011

Portal Roles

Roles are a very useful aspect to an abstract system, especially for systems that have more than one function or application.  These roles are assigned to accounts and in turn these accounts can access said roles.

For my implementation using mongodb, I will follow the same methodology I've used in the past:  role definitions and role permissions.

Mongoose schema definitions:

So, very simply, a role has a description, and its _id is stored in the permission collection for the specific account_id.  A user's account_id is stored in a session server side.  Then, whenever a user requests client javascript or GET/POST data for a specific role, a check to p_roles will be made.

Monday, July 18, 2011

Github repo setup

I synced my code to github for all to admire.  GPL 3.0

New Login Spash uses nodejs logo

Here is what the login screen looks like!

Thanks to the nodejs community for this really awesome splash image.

MongoDB + regular expressions

In traditional SQL databases, one could do a LIKE query and a prefix string to pull a set of data containing the prefix string.

Turns out its relatively easy in mongodb as well.  The only trick is using regular expressions.

For example, I have a collection of accounts.  For each document in this collection, there is a name attribute.  When a user composes a new message, they must select a user to send to.  This combobox can be used to search the accounts collection based on what is typed into the textfield.

Here is how this is achieved on the server side.  The important part is creating a new RegExp object and providing the query string to it:

Friday, July 15, 2011

NodeJS 0.5.1 released

The people over at NodeJS released their latest version of the v8 javascript engine.

Head on over to see the announcement