Exemplo n.º 1
0
 app.db.view('category', 'top_level', {include_docs: true}, app.handleError(res, function(result) {
   if(result.rows.length === 0) {
     res.send([], computeStatusCode(req, 204));
   } else {
     res.send(result.rows.map(function(row) {
       return Category.fromDoc(row.doc).toEmbeddedApi(req);
     }), 200);
   };
 }));
Exemplo n.º 2
0
    app.db.view('attendees', 'by_conference_id', {include_docs: true, key: req.params.id}, app.handleError(res, function(results) {
      count = results.rows.length,
        attendances = [];

      if(count > 0) {
        results.rows.forEach(function(row) {
          attendances.push(Attendance.fromDoc(row.doc).toApi());
          if(attendances.length == count) {
            res.send(attendances);
          };
        });        
      } else {
        res.send([], computeStatusCode(req, 204));
      }
    }));
Exemplo n.º 3
0
 function sendConferences(results, req, res) {
   var count = results.rows.length,
     conferences = [];
   if(results.rows.length == 0) {
     res.send([], computeStatusCode(req, 204));
   } else {
     results.rows.forEach(function(row) {
       Conference.fromDoc(row.doc).toEmbeddedApi(req, app.db, app.handleError(res, function(conference) {
         conferences.push(conference);
         if(conferences.length == count) {
           res.send(conferences);
         };
       }));
     });
   }
 }
Exemplo n.º 4
0
 app.db.saveDoc(doc, app.handleError(res, function(ok) {
   res.send({}, computeStatusCode(req, 204));   
 }));