Skip to content

do-/node-doix-devextreme

Repository files navigation

workflow Jest coverage

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 and offset options are overridden with take and skip respectively;
  • the order list is replaced with the translated sort, if any (so the order passed in argument acts as a default value);
  • the 1st query table filter option is appended with the translated filter.

Limitations

To date, IS NULL predicates are never generated.

About

doix binding for DevExtreme framefork

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published