https://github.com/do-/node-doix-devextreme
doix binding for DevExtreme framefork
https://github.com/do-/node-doix-devextreme
Last synced: about 2 months ago
JSON representation
doix binding for DevExtreme framefork
- Host: GitHub
- URL: https://github.com/do-/node-doix-devextreme
- Owner: do-
- License: other
- Created: 2024-01-28T14:28:09.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-07T17:10:00.000Z (over 1 year ago)
- Last Synced: 2025-10-08T10:31:00.251Z (6 months ago)
- Language: JavaScript
- Size: 128 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README


`doix-devextreme` is a [DevExtreme](https://www.devexpress.com) adapter for the [doix](https://github.com/do-/node-doix) server platform.
As of this writing, it contains only a basic a translator of [AJAX requests](https://js.devexpress.com/jQuery/Documentation/ApiReference/Data_Layer/CustomStore/LoadOptions/) coming from `dxDataGrid` into [DbQuery](https://github.com/do-/node-doix-db/wiki/DbQuery) instances.
# Installation
```
npm install doix-devextreme
```
# Initialization
`doix-devextreme` is a plug in for database clients, such as [DbClientPg](https://github.com/do-/node-doix-db-postgresql/wiki/DbClientPg). It can be attached to any database connection pool by calling the `plugInto` method:
```js
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](https://github.com/do-/node-doix/wiki/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](https://github.com/do-/node-doix-db/wiki/DbModel#createquery):
```js
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.