Skip to content
Browse files

correct syntax error in JS fun.

  • Loading branch information...
1 parent 405e3a3 commit 7bad7dc9bd6e4f5dc5aee3427b8cafc8c63eee2a Robert Newson committed Apr 30, 2009
Showing with 24 additions and 29 deletions.
  1. +24 −29 README.md
View
53 README.md
@@ -148,37 +148,32 @@ doc.attachment("attachment name", {"field":"attachments"});
<pre>
function(doc) {
- var ret = new Document();
-
- function idx(obj) {
- for (var key in obj) {
- switch (typeof obj[key]) {
- case 'object':
- idx(obj[key]);
- break;
- case 'function':
- break;
- default:
- ret.add(obj[key], {"field", key});
- /*
- * Uncomment next line to include
- * all attributes into the default field.
- */
- // ret.add(obj[key]);
- break;
- }
- }
- }
-
- // Index all attributes
- idx(doc);
+ var ret = new Document();
+
+ function idx(obj) {
+ for (var key in obj) {
+ switch (typeof obj[key]) {
+ case 'object':
+ idx(obj[key]);
+ break;
+ case 'function':
+ break;
+ default:
+ ret.add(obj[key]);
+ break;
+ }
+ }
+ };
- // Index all attachments
- for(var a in doc._attachments) {
- ret.add_attachment(a, {"field", "attachments"});
- }
+ idx(doc);
- return ret;
+ if (doc._attachments) {
+ for (var i in doc._attachments) {
+ ret.attachment("attachment", i);
+ }
+ }
+
+ return ret;
}
</pre>

0 comments on commit 7bad7dc

Please sign in to comment.
Something went wrong with that request. Please try again.