O'Reilly logo

Web Application Development with MEAN by Robert Onodi, Adrian Mejia, Amos Q. Haviv

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Thread backend

In the Node.js backend application, we are going make available endpoints, defined in our Express application routes, related to managing conversation threads. Also, there should be a way to get the message history from a specific thread.

Thread controller

We are going to add the necessary business logic to manage our threads in a new controller file, called app/controllers/thread.js, by following these steps:

  1. Add the required modules:
    'use strict';
    
    const mongoose = require('mongoose');
    const Thread = mongoose.model('Thread');
  2. Export the module's methods:
    module.exports.allByUser = allThreadsByUser;
    module.exports.find = findThread;
    module.exports.open = openThread;
    module.exports.findById = findThreadById;
  3. Find all the threads for a specific ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required