doix-devextreme
v1.0.6
Published
doix binding for DevExtreme framefork
Downloads
5
Readme
doix-devextreme
is a DevExtreme adapter for the doix server platform.
As of this writing, it contains only a basic a translator of AJAX requests coming from dxDataGrid
into DbQuery instances.
Installation
npm install doix-devextreme
Initialization
doix-devextreme
is a plug in for database clients, such as DbClientPg. It can be attached to any database connection pool by calling the plugInto
method:
const {DbPoolPg} = require ('doix-db-postgresql')
const dx = require ('doix-devextreme')
const db = new DbPoolPg ({
db: conf.db,
logger: createLogger (conf, 'db'),
})
dx.plugInto (db)
After that, each db
instance injected into a Job will have the dxQuery
method described in the next section.
Using in application code
With doix-devextreme
plugged in, the db
resource provides the dxQuery
method having the same parameters as DbModel.createQuery:
select_users:
async function () {
const {db} = this
const query = db.dxQuery ([['users']], {order: ['label']})
const list = await db.getArray (query)
return {
all: list,
cnt: list [Symbol.for ('count')],
portion: query.options.limit
}
}
In fact, this is the db.model.createQuery
call, but with some additions from this.request.loadOptions
:
- the
limit
andoffset
options are overridden withtake
andskip
respectively; - the
order
list is replaced with the translatedsort
, if any (so theorder
passed in argument acts as a default value); - the 1st query table
filter
option is appended with the translatedfilter
.
Limitations
To date, IS NULL
predicates are never generated.