Как подписаться на экземпляр модели в Sails.JS?

Я пытаюсь использовать функцию подпискиописано здесь, Однако при редактировании/assets/js/app.jsЯ получаю эту ошибку:

Uncaught ReferenceError: Room is not defined 

Итак, я не совсем уверен, почему, но он не может найти мою модель. Вот мой код:

Room.subscribe(req, [{id: "5278861ab9a0d2cd0e000001"}], function (response) {
  console.log('subscribed?');
  console.log(response);
});

а вот это в контексте app.js

(function (io) {

  // as soon as this file is loaded, connect automatically, 
  var socket = io.connect();
  if (typeof console !== 'undefined') {
    log('Connecting to Sails.js...');
  }

  socket.on('connect', function socketConnected() {

    // Listen for Comet messages from Sails
    socket.on('message', function messageReceived(message) {

      ///////////////////////////////////////////////////////////
      // Replace the following with your own custom logic
      // to run when a new message arrives from the Sails.js
      // server.
      ///////////////////////////////////////////////////////////
      log('New comet message received :: ', message);
      //////////////////////////////////////////////////////

    });


    ///////////////////////////////////////////////////////////
    // Here's where you'll want to add any custom logic for
    // when the browser establishes its socket connection to 
    // the Sails.js server.
    ///////////////////////////////////////////////////////////
    log(
        'Socket is now connected and globally accessible as `socket`.\n' + 
        'e.g. to send a GET request to Sails, try \n' + 
        '`socket.get("/", function (response) ' +
        '{ console.log(response); })`'
    );
    ///////////////////////////////////////////////////////////

    // This is the part I added: 
    Room.subscribe(req, [{id: "5278861ab9a0d2cd0e000001"}], function (response) {
      console.log('subscribed?');
      console.log(response);
    });
    //


   });


  // Expose connected `socket` instance globally so that it's easy
  // to experiment with from the browser console while prototyping.
  window.socket = socket;


  // Simple log function to keep the example simple
  function log () {
    if (typeof console !== 'undefined') {
      console.log.apply(console, arguments);
    }
  }


})(

Я иду об этом правильным путем? я должен хранить этопрямо в app.js?

Ответы на вопрос(1)

Ваш ответ на вопрос