mysqlsails.jswaterline

Waterline BIGINT type with sails-mysql


I would like to know how can i define a bigint type in a waterline model using sails-mysql? Couldn't find any proper documentation about it. Seems like it doesn't support bigint types however i really need it. Trying to dig over the sourcecode i found something liek this: https://github.com/balderdashy/sails-mysql/blob/987f4674785970951bc52becdfdb479864106da1/helpers/private/schema/build-schema.js#L29 But it's still not working.

module.exports = {
    attributes: {

        userId: {
            type: 'bigint',
            autoIncrement: true,
            primaryKey: true,
            unique: true,
        },
   }
};

This one still keeps creating an integer field in the database.


Solution

  • Ok after digging through the source code a bit more i figured that i have to set an extra property called size for the field. Setting it to 64 will cause waterline to create a BIGINT field.

    module.exports = {
        attributes: {
    
            userId: {
                type: 'integer',
                size: 64, // waterline will translate this as bigint
                autoIncrement: true,
                primaryKey: true,
                unique: true,
            },
       }
    };