title: Angular.js put request fails with Sails.js and mysql database
body: <p>In my Angular.js service I've created a custom request:</p>
  
  <pre><code>.factory('CalendarService', ['$resource',
            function($resource) {
                return {
                    Update: function(bookingObj) {
                        var BookingResource = $resource('http://localhost:1337/bookings/:id',{
                            id: '@id'
                        }, {
                            'update': {
                                method: 'PUT',
                                isArray: true
                            }
                        });
                        var bookingId = bookingObj.id;
                        return BookingResource.update({
                            id: bookingId
                        }, bookingObj).$promise;
                    }
  </code></pre>
  
  <p>On server side Sails.js seems properly configured with sails-mysql, I can make a get request with no errors, but when I call the update function I receive this error:</p>
  
  <pre><code>error: Sending 500 ("Server Error") response:
  Error (E_UNKNOWN) :: Encountered an unexpected error
  : .findOne() requires a criteria. If you want the first record try  .find().limit(1)
      at module.exports.findOne (C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\adapter\dql.js:143:56)
      at _runOperation (C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:
  400:29)
      at run (C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\query\finders\operations.js:69:8)
      at bound.module.exports.findOne (C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\query\finders
  \basic.js:66:16)
      at bound [as findOne] (C:\prestigeweb\node_modules\sails\node_modules\lodash\dist\lodash.js:729:21)
      at Deferred.exec (C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\query\deferred.js:501:16)
      at updated (C:\prestigeweb\node_modules\sails\lib\hooks\blueprints\actions\update.js:83:9)
      at bound (C:\prestigeweb\node_modules\sails\node_modules\lodash\dist\lodash.js:957:21)
      at applyInOriginalCtx (C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:416:80)
      at wrappedCallback (C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\utils\normalize.js:315:18)    
      at _normalizeCallback.callback.success (C:\prestigeweb\node_modules\sails\node_modules\waterline\node_modules\switchb
  ack\lib\normalize.js:33:31)
      at _switch (C:\prestigeweb\node_modules\sails\node_modules\waterline\node_modules\switchback\lib\factory.js:48:28)
      at C:\prestigeweb\node_modules\sails\node_modules\waterline\lib\waterline\query\dql\update.js:224:9
      at done (C:\prestigeweb\node_modules\sails\node_modules\waterline\node_modules\async\lib\async.js:135:19)
      at C:\prestigeweb\node_modules\sails\node_modules\waterline\node_modules\async\lib\async.js:32:16
      at C:\prestigeweb\node_modules\sails\node_modules\waterline\node_modules\async\lib\async.js:157:25 
  Details:  Error: .findOne() requires a criteria. If you want the first record try .find().limit(1)
  </code></pre>
  
  <p>This is the HTTP request from Postman:</p>
  
  <pre><code>PUT /bookings/6397 HTTP/1.1
  Host: localhost:1337
  Accept: application/json, text/plain, */*
  Origin: http://localhost:8100
  X-DevTools-Emulate-Network-Conditions-Client-Id: ABAC3370-A7E6-42AA-A5DA-BA0205880B9C
  X-FirePHP-Version: 0.0.6
  User-Agent: Mozilla/5.0 (iPad; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5
  Content-Type: application/json;charset=UTF-8
  DNT: 1
  Referer: http://localhost:8100/
  Accept-Encoding: gzip, deflate, sdch
  Accept-Language: it-IT,it;q=0.8,en-US;q=0.6,en;q=0.4,fr;q=0.2
  Cache-Control: no-cache
  Postman-Token: 0a627a0a-2f27-0e55-737f-5e838e1084e0
  
  {"id":6397,bla bla bla}
  </code></pre>
  
  <p>this is how I configured Sails.js:</p>
  
  <p>1) sails generate api bookings</p>
  
  <p>2) npm-install sails-mysql</p>
  
  <p>3) inserted in config/connections.js the following line</p>
  
  <pre><code>mysql: {
      adapter: 'sails-mysql',
      host: 'localhost',
      port: 3306,
      user: 'root',
      password: '',
      database: 'prestige'
    },
  </code></pre>
  
  <p>4) added to config/cors.js:</p>
  
  <pre><code>allRoutes: true,
  
  methods: 'GET, POST, PUT, DELETE, OPTIONS, HEAD'
  
  origin: '*'
  </code></pre>
  
  <p>5) on config/model.js added </p>
  
  <pre><code>module.exports.models = {
  
    connection: 'mysql',
  
     migrate: 'safe'
  
  };
  </code></pre>
  
  <p>The sails.js: model:</p>
  
  <pre><code>module.exports = {
  
  tableName: 'prenotazioni',
  adapter: 'mysql',
  //migrate: 'safe',
  autoCreatedAt: false,
  autoUpdatedAt: false,
  
  attributes: {
  
    id: {
        type: 'integer'
    },
    numero_prenotazione: {
        type: 'string'
    },
    nome: {
        type: 'string'
    },
    cognome: {
        type: 'string'
    },
    civico: {
        type: 'string'
    },
    indirizzo: {
        type: 'string'
    },
    ditta: {
        type: 'string'
    },
    cap: {
        type: 'string'
    },
    citta: {
        type: 'string'
    },
    nazione: {
        type: 'string'
    },
    lingua: {
        type: 'string'
    },
    telefono: {
        type: 'string'
    },
    email: {
        type: 'string'
    },
    agente: {
        type: 'string'
    },
    numero_camere: {
        type: 'integer'
    },
    numero_ospiti: {
        type: 'integer'
    },
    costo_totale_camere: {
        type: 'integer'
    },
    ospite_1: {
        type: 'string'
    },
  
    ospite_2: {
        type: 'string'
    },
    camera_1: {
        type: 'string'
    },
  
    camera_2: {
        type: 'string'
    },
    numero_persone_1: {
        type: 'integer'
    },
    numero_persone_2: {
        type: 'integer'
    },
    data_prenotazione: {
        type: 'date'
    },
    data_arrivo_1: {
        type: 'date'
    },
    data_arrivo_2: {
        type: 'date'
    },
    data_partenza_1: {
        type: 'date'
    },
    data_partenza_2: {
        type: 'date'
    },
    quantita_1: {
        type: 'integer'
    },
    quantita_2: {
        type: 'integer'
    },
    totale_1: {
        type: 'integer'
    },
    totale_2: {
        type: 'integer'
    },
    prezzo_1: {
        type: 'integer'
    },
    prezzo_2: {
        type: 'integer'
    },
    status_1: {
        type: 'integer'
    },
    status_2: {
        type: 'integer'
    },
    duration: {
        type: 'string'
    }
   }
  };
  </code></pre>