title: Provide method to handle GET on a Loopback model, whose db is null and base class is 'Model'
body: <h2>RESOLVED. MY BAD.</h2>
  
  <p>Skip to the end of this post, and change <a href="http://localhost:3000/api/Setan/getXid/1" rel="nofollow noreferrer">http://localhost:3000/api/Setan/getXid/1</a> to <a href="http://localhost:3000/api/Setans/getXid/1" rel="nofollow noreferrer">http://localhost:3000/api/Setans/getXid/1</a> ... and it works.</p>
  
  <p>Use the plural form in the URL....</p>
  
  <h2>My comment on UPDATE 02 is also invalid.</h2>
  
  <hr>
  
  <p>Seems like I can't attach a remote method on a model that's configured this way in model-config.json:</p>
  
  <pre><code>"Dashboard": {
    "dataSource": null,
    "public": true
  }
  </code></pre>
  
  <p>*) I'm using loopback ver. 3.0.0.</p>
  
  <p>Screenshot of "lb model":</p>
  
  <p><a href="https://i.stack.imgur.com/lkn01.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lkn01.png" alt="enter image description here"></a></p>
  
  <p>I want to have an endpoint like this: <a href="http://localhost:3000/api/Dashboard/experiment/2017-04-03T14:16:44-05:00" rel="nofollow noreferrer">http://localhost:3000/api/Dashboard/experiment/2017-04-03T14:16:44-05:00</a></p>
  
  <p>So, my common/models/dashboard.js is like this:</p>
  
  <pre><code>module.exports = function(Dashboard) {
    Dashboard.remoteMethod('experiment', {
      accepts: [
        {arg: 'dateStr', type: 'string', required: true}
      ],
      http: {path: '/experiment/:dateStr', verb: 'get'},
      returns: {arg: 'count', type: 'number'}
    });    
  
    Dashboard.experiment = function(dateStr, cb) {
      cb(null, {answer: "yes"});
    }
  };
  </code></pre>
  
  <p>Called in from a REST client, I got:</p>
  
  <pre><code>{
    "error": {
      "statusCode": 404,
      "name": "Error",
      "message": "There is no method to handle GET /Dashboard/experiment/2017-04-03T14:16:44-05:00",
      "stack": "Error: There is no method to handle GET /Dashboard/experiment/2017-04-03T14:16:44-05:00\n    
        at restUrlNotFound (/Users/raka/Development/MyAngular/NewBeginning/baktun-dashboard-server/node_modules/strong-remoting/lib/rest-adapter.js:366:17)\n .... "
    }
  }
  </code></pre>
  
  <p>So... I tried with another case, this time a model that extends Model (just like Dashboard), but db is not-null (I set to to memory-db). Here's the entry in model-config.js:</p>
  
  <pre><code>"Manusia": {
    "dataSource": "db",
    "public": true
  }
  </code></pre>
  
  <p>And in common/models/manusia.js exactly the same remote-method definition:</p>
  
  <pre><code>module.exports = function(Manusia) {
    Manusia.remoteMethod('experiment', {
      accepts: [
        {arg: 'dateStr', type: 'string', required: true}
      ],
      http: {path: '/experiment/:dateStr', verb: 'get'}, 
      returns: {arg: 'count', type: 'number'}
    });    
  
    Manusia.experiment = function(dateStr, cb) {
      cb(null, {answer: "yes"});
    }
  };
  </code></pre>
  
  <p>It works, I called <a href="http://localhost:3000/api/Manusia/experiment/2017-04-03T14:16:44-05:00" rel="nofollow noreferrer">http://localhost:3000/api/Manusia/experiment/2017-04-03T14:16:44-05:00</a> from REST client, and I get:</p>
  
  <pre><code>{
    "count": {
      "answer": "yes"
    }
  }
  </code></pre>
  
  <p><strong>The question</strong>: is there a step I'm missing in order to be able to specify GET handler / remote method for a model that doesn't have datasource?</p>
  
  <p>I know I can always write it in /server/boot/routes.js or server/server.js ( <a href="https://loopback.io/doc/en/lb3/Add-a-custom-Express-route.html" rel="nofollow noreferrer">https://loopback.io/doc/en/lb3/Add-a-custom-Express-route.html</a> )... but..., I like to have my stuffs neatly organized under common/models... so that's why first I want to know if I can really achieve that by having a remote method on non-persisted &amp; "non-attached to any db" model.</p>
  
  <p>Oh wait, actually there is a better reason to have it in a model; so Incan have the corresponding method in the generated angular-client lib. So yes, I need it.</p>
  
  <p><strong>UPDATE 01</strong> </p>
  
  <p>Actually it is unreliable. I cannot reproduce the success case in some (many) ocassions..., and sometimes (few times) I can.</p>
  
  <p>So....</p>
  
  <p><strong>UPDATE 02</strong></p>
  
  <p>Found out that the name of remote method is registered globally. Meaning: you can't both these (the share the same name for the remote method):</p>
  
  <pre><code>Kuda.remoteMethod('yeah', ...)
  </code></pre>
  
  <p>and </p>
  
  <pre><code>Anjing.remoteMethod('yeah', ...)
  </code></pre>
  
  <p>You must ensure uniqueness of remoteMethod name. So, this one is ok:</p>
  
  <pre><code>Kuda.remoteMethod('yeah', ...)
  Anjing.remoteMethod('hurray', ...)
  </code></pre>
  
  <p>But still, it doesn't work for the no-datasource Model.</p>
  
  <p><strong>UPDATE 03</strong></p>
  
  <p>Back to square one. Seems like it's unreliable / inconsistent. Failing again in most cases, even after taking into account UPDATE-02</p>
  
  <p><a href="https://i.stack.imgur.com/3oWdT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3oWdT.png" alt="enter image description here"></a></p>
  
  <p>Almost identical, but different success status. <a href="http://localhost:3000/api/Manusia/getId/1" rel="nofollow noreferrer">http://localhost:3000/api/Manusia/getId/1</a> works, while <a href="http://localhost:3000/api/Setan/getXid/1" rel="nofollow noreferrer">http://localhost:3000/api/Setan/getXid/1</a> doesn't work.</p>
  
  <p>Any clues?</p>
  
  <p>Thanks,
  Raka</p>