E:\sails_app\activeityOverload>sails lift
info: Starting app...
-----------------------------------------------------------------
Excuse my interruption, but it looks like this app
does not have a project-wide "migrate" setting configured yet.
(perhaps this is the first time you're lifting it with models?)
In short, this setting controls whether/how Sails will attempt to automatically
rebuild the tables/collections/sets/etc. in your database schema.
You can read more about the "migrate" setting here:
http://sailsjs.org/#/documentation/concepts/ORM/model-settings.html?q=migrate In a production environment (NODE_ENV==="production") Sails always uses
migrate:"safe" to protect inadvertent deletion of your data.
However during development, you have a few other options for convenience:
1. safe - never auto-migrate my database(s). I will do it myself (by hand)
2. alter - auto-migrate, but attempt to keep my existing data (experimental)
3. drop - wipe/drop ALL my data and rebuild models every time I lift Sails
What would you like Sails to do?
info: To skip this prompt in the future,set`sails.config.models.migrate`.
info: (conventionally, this is done in `config/models.js`)
warn: ** DO NOT CHOOSE "2" or "3"IF YOU ARE WORKING WITH PRODUCTION DATA **
prompt: ?: error: Error: The hook `orm` is taking too long to load.
Make sure it is triggering its `initialize()` callback, or elseset `sails.config.orm._hookTimeout to a higher value (currently 20000)
at tooLong [as _onTimeout] (C:\Users\KennyTu\AppData\Roaming\npm\node_modules\sails\lib\app\private\loadHooks.js:92:21)
at Timer.listOnTimeout (timers.js:89:15)
module.exports.models={/*************************************************************************** * * * Your app's default connection. i.e. the name of one of your app's * * connections (see `config/connections.js`) * * * ***************************************************************************/// connection: 'localDiskDb',/*************************************************************************** * * * How and whether Sails will attempt to automatically rebuild the * * tables/collections/etc. in your schema. * * * * See http://sailsjs.org/#!/documentation/concepts/ORM/model-settings.html * * * ***************************************************************************/migrate:'safe'};
把migrate改成safe, 再重新執行sails lift
基本上應該就沒問題可以正常執行了
接下來開啟瀏覽器, 輸入底下網址..
作者在輸入到一半的時候,故意只輸入部分, 來讓我們看一下出錯的效果
http://localhost:1337/user/create?name=kenny
伺服器回應的結果是:
123456789101112131415161718
{"error":"E_VALIDATION","status":400,"summary":"1 attribute is invalid","model":"User","invalidAttributes":{"email":[{"rule":"email","message":"`undefined` should be a email (instead of \"null\", which is a object)"},{"rule":"required","message":"\"required\" validation rule failed for input: null"}]}}