Skip to content

Custom type.datastoreSelect as a default prop.select - #376

Closed
kapouer wants to merge 2 commits into
dresende:masterfrom
kapouer:type-select
Closed

kapouer wants to merge 2 commits into
dresende:masterfrom
kapouer:type-select

Conversation

@kapouer

@kapouer kapouer commented Nov 6, 2013

Copy link
Copy Markdown
Contributor

This follows #375

Typical example on a PostGIS table

orm.db.defineType('GeoJSON', {
    datastoreType: function(prop) {
        return 'geometry(Geometry, 4326)';
    },
    datastoreSelect: function(prop, helper) {
        return 'ST_AsGeoJSON(' + prop + ') AS ' + prop;
    },
    valueToProperty: function(value, prop) {
        return JSON.parse(value);
    },
    propertyToValue: function(value, prop) {
        return "ST_SetSRID(ST_GeomFromGeoJSON('" + JSON.stringify(value) + "'), 4326)";
    }
});

This is a generic way to address
dresende#273
Important: property.select can be a function, whose
return value won't be escaped.
This sets a default 'select' for custom types, see:
dresende#375
@kapouer

kapouer commented May 29, 2014

Copy link
Copy Markdown
Contributor Author

N/A

@kapouer kapouer closed this May 29, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant