@uql/mongo
Advanced tools
Comparing version 0.4.65 to 0.4.66
@@ -6,3 +6,3 @@ { | ||
"license": "MIT", | ||
"version": "0.4.65", | ||
"version": "0.4.66", | ||
"main": "index.js", | ||
@@ -25,3 +25,3 @@ "types": "index.d.ts", | ||
"@types/node": "^16.4.8", | ||
"@uql/core": "^0.4.65", | ||
"@uql/core": "^0.4.66", | ||
"copyfiles": "^2.4.1", | ||
@@ -28,0 +28,0 @@ "rimraf": "^3.0.2", |
@@ -41,11 +41,11 @@ # [uql](https://uql.io) · [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/impensables/uql/blob/master/LICENSE) [![tests](https://github.com/impensables/uql/actions/workflows/tests.yml/badge.svg)](https://github.com/impensables/uql) [![coverage status](https://coveralls.io/repos/impensables/uql/badge.svg?branch=master)](https://coveralls.io/r/impensables/uql?branch=master) [![npm version](https://badge.fury.io/js/%40uql%2Fcore.svg)](https://badge.fury.io/js/%40uql%2Fcore) | ||
```sh | ||
npm install @uql/core --save | ||
``` | ||
```sh | ||
npm install @uql/core --save | ||
``` | ||
or | ||
or | ||
```sh | ||
yarn add @uql/core | ||
``` | ||
```sh | ||
yarn add @uql/core | ||
``` | ||
@@ -324,2 +324,4 @@ 1. Install one of the following packages according to your database: | ||
import * as express from 'express'; | ||
import { augmentFilter } from '@uql/core/util'; | ||
import { Query, EntityMeta } from '@uql/core/type'; | ||
import { querierMiddleware } from '@uql/express'; | ||
@@ -343,8 +345,5 @@ | ||
// e.g. for multi tenant apps. | ||
augmentQuery<E>(entity: Type<E>, qm: Query<E>, req: Request): Query<E> { | ||
qm.$filter = { | ||
...qm.$filter, | ||
// ensure the user can only see the data that belongs to his company. | ||
companyId: req.identity.companyId, | ||
}; | ||
augmentQuery: <E>(meta: EntityMeta<E>, qm: Query<E>, req: express.Request): Query<E> => { | ||
// ensure the user can only see the data that belongs to the related company. | ||
qm.$filter = augmentFilter(qm.$filter, { companyId: req.identity.companyId }); | ||
return qm; | ||
@@ -351,0 +350,0 @@ }, |
64115
383