Teach Me To Code » Screencasts

Followers and Following


Listen Later

In order to get someone a timeline in JotRod, we need followers and following lists to compile the Jots from. This means that we need to add a new ColumnFamily called Followers and another one called Following. We don't have the joins capability from relational databases to do this for us.
I'm going to hijack the User model's database connection to create the ColumnFamilies. (We don't have migrations, yet.) Here's what I ran in the rails console:
cf_def = CassandraThrift::CfDef.new(:keyspace => "JotRod", :name => "Followers")
User.connection.add_column_family(cf_def)
cf_def = CassandraThrift::CfDef.new(:keyspace => "JotRod", :name => "Following")
User.connection.add_column_family(cf_def)
Now that we have the ColumnFamilies, I want to have syntax like this to define the relationships on the User model:
list :followers, :User
list :following, :User
This should provide the following API:
#followers - returns an array of users as specified from the Followers ColumnFamily
#followers<<(user)  - adds the user to the User object's followers list if it's not already there
and a similar API for following.
Sandra's repository
JotRod's repository
Download 680 MB
Download (iPod & iPhone) 165 MB
Take the 2011 Readers Survey
...more
View all episodesView all episodes
Download on the App Store

Teach Me To Code » ScreencastsBy Charles Max Wood

  • 4.5
  • 4.5
  • 4.5
  • 4.5
  • 4.5

4.5

11 ratings


More shows like Teach Me To Code » Screencasts

View all
JavaScript Jabber by Charles M Wood

JavaScript Jabber

235 Listeners

iPhreaks by Charles M Wood

iPhreaks

17 Listeners

Ruby Rogues by Charles M Wood

Ruby Rogues

45 Listeners

The Freelancers' Show by Charles M Wood

The Freelancers' Show

23 Listeners

Adventures in Angular by Charles M Wood

Adventures in Angular

33 Listeners

React Native Radio by Jamon Holmgren, Robin Heinze, Mazen Chami

React Native Radio

59 Listeners

My JavaScript Story by Charles M Wood

My JavaScript Story

4 Listeners

JavaScript Jabber by Charles M Wood

JavaScript Jabber

61 Listeners

Ruby Rogues by Charles M Wood

Ruby Rogues

21 Listeners

Adventures in Angular by Charles M Wood

Adventures in Angular

15 Listeners