Skip to content

Instantly share code, notes, and snippets.

@davidcoallier
Created March 1, 2010 17:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidcoallier/318571 to your computer and use it in GitHub Desktop.
Save davidcoallier/318571 to your computer and use it in GitHub Desktop.
diff --git a/models/SphereView.php b/models/SphereView.php
index 5e778d2..f7b8b26 100644
--- a/models/SphereView.php
+++ b/models/SphereView.php
@@ -13,14 +13,14 @@ class SphereView extends \lithium\data\Model {
'views' => array(
'posts' => array(
'map' => 'function(doc) {
- if (doc.type == "post") {
+ if (doc.type && doc.type == "post" && doc.created) {
emit(doc.created, doc);
}
}'
),
'users' => array(
'map' => 'function(doc) {
- if (doc.type == "user") {
+ if (doc.type && doc.type == "user" && doc.created) {
emit(doc.created, doc);
}
}'
@@ -32,8 +32,8 @@ class SphereView extends \lithium\data\Model {
'language' => 'javascript',
'views' => array(
'by_username' => array(
- 'map' => 'function(doc) {
- if(doc.type == "user") {
+ 'map' => 'function(doc) {
+ if(doc.type && doc.type == "user" && doc.username) {
emit(doc.username, doc);
}
}'
@@ -50,4 +50,4 @@ class SphereView extends \lithium\data\Model {
}
}
-?>
\ No newline at end of file
+?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment