ActiveRecord like implementation in Javascript