Waterline BIGINT type with sails-mysql

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.


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,
        },
   }
};

Attributes, Here is a list of the data types supported by Sails and Waterline: string; number; boolean; json; ref. Required. #. If an attribute is required: true , then a value  3 Waterline BIGINT type with sails-mysql Apr 7 '17 3 How to get only path from full url string Jun 3 '19 3 Unreal Engine 4: C++ Delegate not being called Jul 16 '19


Another way is to use the following attributes:

{
   type: 'string',
   columnType: 'bigint'
}

This ignores Waterline data types and forces Postgres/MySQL column data type directly.

MySQL, Now when i fetch records in sails js, the a record in the result has a value with an unexpected data type for property user_id . were added or modified in your database from somewhere outside of Sails/Waterline No support for custom Postgres types (bigint, bytea, array). If you set a column to type 'array' in Waterline, it creates a text field in the database and serializes the array by calling JSON.stringify. If you define a column to be type 'integer', Waterline will reject things that don't look like integers


Edit: I hadn't tested this thoroughly. It isn't working, after all.

The property size isn't allowed for model attributes in Sails v1.0+, but this seems to work. I pulled it from the definition of the createdAt attribute in the waterline library (line 485, as of this writing).

module.exports = {
  attributes: {
    timeOfDay: {
      type: 'number',
      autoMigrations: { columnType: '_numbertimestamp' }
    }
  }
};

columnType 'bigint' not working · Issue #5264 · balderdashy/sails , I'm currently facing a strange issue using columnType: 'bigint' which is raising a warning (see attachment). Here is my Model.js The type property is a Waterline abstraction; the sails-postgres adapter just gets a column  Waterline version:0.13-rc9 Node version:7.9.0 NPM version:5.0.2 Operating system:Windows 10 Professional x64 Since removal of datetime attribute type, the console suggested I set the type to string and columnType to 'datetime'.


Sails-MySQL Adapter . MySQL adapter for the Sails framework and Waterline ORM. Allows you to use MySQL via your models to store and retrieve data. Also provides a query() method for a direct interface to execute raw SQL commands. Installation. Install from NPM. #


Waterline (ORM) By default, new Sails apps are bundled with an ORM called Waterline (implemented in the sails-hook-orm dependency). To learn more about using Waterline, start in Concepts > Models & ORM. Reference. This section of the documentation contains a reference of all of the methods available at runtime on models, queries, and datastores.


11.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT MySQL supports the SQL standard integer types INTEGER (or INT ) and SMALLINT . As an extension to the standard, MySQL also supports the integer types TINYINT , MEDIUMINT , and BIGINT .