Permalink
Browse files

Re-add views

  • Loading branch information...
1 parent 3d64c50 commit 258d9c0a5acf4b271db062b4047a9317d639724a @avsej avsej committed Apr 3, 2012
View
@@ -9,6 +9,8 @@ class Link < Couchbase::Model
attribute :views, :default => 0
attribute :created_at, :default => lambda { Time.zone.now }
+ view :by_created_at, :by_session_id, :by_view_count
+
define_model_callbacks :save
validates :url, :presence => true, :url => {:allow_nil => true, :message => "This is not a valid URL"}
before_save :generate_key
@@ -0,0 +1,5 @@
+function(doc) {
+ if(doc.type == "link" && doc.created_at != null) {
+ emit(doc.created_at, null);
+ }
+}
@@ -0,0 +1,5 @@
+function(doc) {
+ if(doc.type == "link" && doc.session_id != null) {
+ emit(doc.session_id, null);
+ }
+}
@@ -0,0 +1,5 @@
+function(doc) {
+ if(doc.type == "link") {
+ emit(doc.views, null);
+ }
+}

0 comments on commit 258d9c0

Please sign in to comment.