Also bin ich mit SailsJS rum, um zu versuchen, eine API schnell zu bekommen. Ich habe noch keinen Datenspeicher eingerichtet (wird wahrscheinlich mongodb verwenden), aber ich habe gesehen, dass es sich dabei um eine SQLite-Datenbank handelt. Also habe ich ein Model und einen Controller für einen User generiert. Also im Browser treffe ich user/create. Ich sehe createdAt und updatedAt, aber keine ID. Benötige ich einen echten Datenspeicher, um eine ID zu sehen? Ist das noch etwas, was du kostenlos bekommst?ID in Sails JS Antwort nicht sehen
Adapter
// Configure installed adapters
// If you define an attribute in your model definition,
// it will override anything from this global config.
module.exports.adapters = {
// If you leave the adapter config unspecified
// in a model definition, 'default' will be used.
'default': 'disk',
// In-memory adapter for DEVELOPMENT ONLY
// (data is NOT preserved when the server shuts down)
memory: {
module: 'sails-dirty',
inMemory: true
},
// Persistent adapter for DEVELOPMENT ONLY
// (data IS preserved when the server shuts down)
// PLEASE NOTE: disk adapter not compatible with node v0.10.0 currently
// because of limitations in node-dirty
// See https://github.com/felixge/node-dirty/issues/34
disk: {
module: 'sails-dirty',
filePath: './.tmp/dirty.db',
inMemory: false
},
// MySQL is the world's most popular relational database.
// Learn more: http://en.wikipedia.org/wiki/MySQL
mysql: {
module : 'sails-mysql',
host : 'YOUR_MYSQL_SERVER_HOSTNAME_OR_IP_ADDRESS',
user : 'YOUR_MYSQL_USER',
password : 'YOUR_MYSQL_PASSWORD',
database : 'YOUR_MYSQL_DB'
}
};
Modell
/*---------------------
:: User
-> model
---------------------*/
module.exports = {
attributes: {
firstName: 'STRING',
lastName: 'STRING'
}
};
Versuchen Sie, dies zu Ihrem Modell hinzuzufügen. 'autoPk: true,' – Travis