PhilWaldmann / openrecord

Make ORMs great again!
https://openrecord.js.org
MIT License
486 stars 38 forks source link

how to use alias in requests #40

Closed stts-x closed 7 years ago

stts-x commented 7 years ago

if i write myBase.Model('good').select("goods.id AS 'sku'").exec() i receive result with out field 'sku', and field goods.id = null

PhilWaldmann commented 7 years ago

add .asRaw() after the select(...) to get the raw output. OpenRecord only processes the known fields in normal mode. With .asRaw() you could force it to output everything your db returns.

As an alternative you could add an offline attribute to your model definition:

this.attribute('sku', Number)
PhilWaldmann commented 7 years ago

btw: I don't think it's necessary to use quotes around sku.