Sails-mysql schema data types

Has anyone used node sails using mysql as a DB ( https://github.com/balderdashy/sails-mysql )?

I am stuck in models, I cannot create a database structure. The data types that I need to use to create the schema do not work. I searched everywhere for documentation, but I can not find anything that could help me.

Sailing documentation is not completed yet, I think. http://sailsjs.org/#documentation/models

Can anybody help me in creating models. I would really appreciate it if you can help me create a simple schema below using sails-mysql. Thanks in advance!

module.exports = { attributes: { id: 'FLOAT', social_network: { type: 'ENUM', defaultsTo : {'Facebook', 'twitter', 'vk','weibo'} }, country: 'STRING', message: 'TEXT', link: 'STRING', comments: 'TEXT', userid: 'INT', username: 'STRING', image_link: 'STRING', longitude: 'FLOAT', latitude: 'FLOAT', location_name: 'STRING', updated_at: 'TIMESTAMP', created_at: 'TIMESTAMP' } }; 
+7
source share
1 answer

I am the author of Waterline, it’s a pity that you could not find what you needed in the documents, we are constantly working on adding them and keeping them up to date.

You are very close to your pattern. Waterline does not currently support the ENUM database type, but we have checks that will allow you to get the same end result.

 module.exports = { // Disables Automatic ID generation // (allows you to use a FLOAT type for your ID) autoPK: false, // Disables Automatic Timestamps // You will need to manually update your timestamps, usually best to leave this // on and remove the updated_at and created_at attributes below to let Waterline // keep these up to date for you autoCreatedAt: false, autoUpdatedAt: false, attributes: { id: { type: 'FLOAT', primaryKey: true } // Proper ENUM types at the Database level are not yet supported // but you can use validations to achieve the same end result. // You can also add a default social_network with defaultsTo social_network: { type: 'STRING', in: ['facebook', 'twitter', 'vk', 'weibo'] }, country: 'STRING', message: 'TEXT', link: 'STRING', comments: 'TEXT', userid: 'INTEGER', username: 'STRING', image_link: 'STRING', longitude: 'FLOAT', latitude: 'FLOAT', location_name: 'STRING', // Timestamp is not supported but Time, Date, and DateTime are updated_at: 'DATETIME', created_at: 'DATETIME' } }; 
+27
source share

All Articles