Documentation
    Preparing search index...

    A column storing Geometry information. It is only available in PostgreSQL (with PostGIS), MariaDB or MySQL.

    GeoJSON is accepted as input and returned as output.

    In PostGIS, the GeoJSON is parsed using the PostGIS function STGeomFromGeoJSON. In MySQL it is parsed using the function STGeomFromText.

    Therefore, one can just follow the GeoJSON spec for handling geometry objects. See the following examples:

    Fallback policy: If this type is not supported, an error will be raised.

    DataTypes.GEOMETRY
    DataTypes.GEOMETRY('POINT')
    DataTypes.GEOMETRY('POINT', 4326)
    const point = { type: 'Point', coordinates: [-76.984722, 39.807222]}; // GeoJson format: [lng, lat]

    User.create({username: 'username', geometry: point });
    const line = { type: 'LineString', 'coordinates': [ [100.0, 0.0], [101.0, 1.0] ] };

    User.create({username: 'username', geometry: line });
    const polygon = { type: 'Polygon', coordinates: [
    [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
    [100.0, 1.0], [100.0, 0.0] ]
    ]};

    User.create({username: 'username', geometry: polygon });
    const point = {
    type: 'Point',
    coordinates: [-76.984722, 39.807222], // GeoJson format: [lng, lat]
    crs: { type: 'name', properties: { name: 'EPSG:4326'} }
    };

    User.create({username: 'username', geometry: point })

    Hierarchy (View Summary)

    Index
    usageContext: DataTypeUseContext | undefined

    Where this DataType is being used.

    • Override this method to emit an error or a warning if the Data Type, as it is configured, is not compatible with the current dialect.

      Parameters

      Returns void

    • Whether this DataType wishes to handle NULL values itself. This is almost exclusively used by JSON and JSONB which serialize null as the JSON string 'null'.

      Returns boolean

    • Returns a copy of this DataType, without usage context. Designed to re-use a DataType on another Model.

      Returns this

    • Escapes a value for the purposes of inlining it in a SQL query. The resulting value will be inlined as-is with no further escaping.

      Parameters

      • value: GeoJson

        The value to escape.

      Returns string

    • This method is called when AbstractQueryGenerator needs to add a bind parameter to a query it is building. This method allows for customizing both the SQL to add to the query, and convert the bind parameter value to a DB-compatible value.

      If you only need to prepare the bind param value, implement toBindableValue instead.

      This method must return the SQL to add to the query. You can obtain a bind parameter ID by calling BindParamOptions#bindParam with the value associated to that bind parameter.

      An example of a data type that requires customizing the SQL is the GEOMETRY data type.

      Parameters

      Returns string

    • Called when a value is retrieved from the Database, and its DataType is specified. Used to normalize values from the database.

      Note: It is also possible to do an initial parsing of a Database value using AbstractDialect#registerDataTypeParser. That normalization uses the type ID from the database instead of a Sequelize Data Type to determine which parser to use, and is called before this method.

      Parameters

      • value: unknown

        The value to parse.

      Returns unknown

    • Used to normalize a value when Model#set is called. That is, when a user sets a value on a Model instance.

      Parameters

      • value: unknown

      Returns unknown

    • Converts a JS value to a value compatible with the connector library for this Data Type. Unlike escape, this value does not need to be escaped. It is passed separately to the database, which will handle escaping.

      Parameters

      • value: GeoJson

        The value to convert.

      Returns unknown

    • Returns a SQL declaration of this data type. e.g. 'VARCHAR(255)', 'TEXT', etc…

      Returns string

    • Returns string

    • Checks whether the JS value is compatible with (or can be converted to) the SQL data type. Throws if that is not the case.

      Parameters

      • value: unknown

      Returns asserts value is GeoJson

    • Returns string