Skip to content

Commit

Permalink
update nested query listener (#135)
Browse files Browse the repository at this point in the history
* update nested query listener

* 2.11.2
  • Loading branch information
kbarbounakis committed Jan 9, 2024
1 parent 9f2bc49 commit 12bfa2d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ jobs:
node-version: [14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: npm test
run: |
npm i
npm ci
npx @themost/peers
npm test
env:
Expand Down
20 changes: 6 additions & 14 deletions OnNestedQueryListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,15 @@ class OnNestedQueryListener {
return Promise.resolve();
}
if (Object.prototype.hasOwnProperty.call(query, '$expand')) {
/**
* @type {{ $entity:{ model:string }} | Array<{ $entity:{ model:string }}>}
*/
const expand = query.$expand;
// exit if expand is null or undefined
if (expand == null) {
if (query.$expand == null) {
return Promise.resolve();
}
if (Array.isArray(expand)) {

/**
* @type {Array<{ $entity:{ model:string }}>}
*/
const expand = Array.isArray(query.$expand) ? query.$expand : [query.$expand];
if (expand.length) {
const sources = expand.map(function (item) {
return function () {
// if entity is already a query expression
Expand Down Expand Up @@ -158,13 +157,6 @@ class OnNestedQueryListener {
}
});
return Promise.sequence(sources);
} else if (expand && expand.$entity && expand.$entity.model) {
// get nested model
const model = context.model(expand.$entity.model);
if (model != null) {
//
return Promise.resolve();
}
}
}
return Promise.resolve();
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@themost/data",
"version": "2.11.1",
"version": "2.11.2",
"description": "MOST Web Framework Codename Blueshift - Data module",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 12bfa2d

Please sign in to comment.