Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 2 commits into from

Conversation

kapouer
Copy link
Contributor

@kapouer kapouer commented Nov 6, 2013

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
Copy link
Contributor Author

kapouer commented May 29, 2014

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