Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Views

  • Loading branch information...
commit 84267a4c12f82c833ffeb9401d30accea063ccf5 1 parent c6b499b
@topfunky authored
View
2  app/models/basic_model.rb
@@ -41,7 +41,7 @@ def self.db(database_name)
database = CouchRest.database!(full_url_to_database)
# Synchronize views
file_manager = CouchRest::FileManager.new(File.basename(full_url_to_database))
- file_manager.push_views(File.join(Rails.root, "couchdb_views"))
+ file_manager.push_views(File.join(Rails.root, "db", "views"))
database
end
View
2  app/models/note.rb
@@ -10,7 +10,7 @@ def default_attributes
end
##
- # Coerce things into the proper types of objects.
+ # Coerce fields into the proper types of objects.
def on_update
if (tags = @attributes['tags']) && tags.is_a?(String)
View
10 couchdb_views/notes/by_visited_on-map.js
@@ -1,10 +0,0 @@
-function(doc) {
- if (doc.type == "Note" && doc.visited_on) {
- date_array = doc.visited_on.split("/");
- date_array = date_array.map(function(d) {
- return parseInt(d, 10);
- });
- // Or, Date.parse(doc.visited_on) for a timestamp
- emit(date_array, doc);
- }
-}
View
4 couchdb_views/notes/lib.js
@@ -1,4 +0,0 @@
-// Put functions specific to 'notes' here.
-// Include in your views with
-//
-// //include-lib
View
0  couchdb_views/lib.js → db/views/lib.js
File renamed without changes
View
0  couchdb_views/notes/by_tag-map.js → db/views/notes/by_tag-map.js
File renamed without changes
View
0  couchdb_views/notes/by_tag-reduce.js → db/views/notes/by_tag-reduce.js
File renamed without changes
View
0  couchdb_views/notes/by_title-map.js → db/views/notes/by_title-map.js
File renamed without changes
View
0  couchdb_views/notes/by_updated_at-map.js → db/views/notes/by_updated_at-map.js
File renamed without changes
View
6 db/views/notes/by_visited_on-map.js
@@ -0,0 +1,6 @@
+//include-lib
+function(doc) {
+ if (doc.type == "Note" && doc.visited_on) {
+ emit(Util.dateAsArray(doc.visited_on), doc);
+ }
+}
View
11 db/views/notes/lib.js
@@ -0,0 +1,11 @@
+// Put functions specific to 'notes' here.
+// Include in your views with
+//
+// //include-lib
+
+Util = {
+ "dateAsArray": function(date_string) {
+ date = new Date(date_string);
+ return [date.getFullYear(), date.getMonth() + 1, date.getDay()];
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.