Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ executors:
# Orbs

orbs:
node: circleci/node@5.2.0
node: circleci/node@7.0.0

################################
# Jobs
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node_version: [18, 20, 21]
node_version: [20, 22, 23]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# [0.93.0](https://github.com/5app/dare/compare/v0.92.1...v0.93.0) (2025-01-23)


### Features

* **state:** attach state to each tree node, fixes [#392](https://github.com/5app/dare/issues/392) ([#393](https://github.com/5app/dare/issues/393)) ([5221086](https://github.com/5app/dare/commit/522108626a64b68eef9d0865771a711ac1401735))

## [0.92.1](https://github.com/5app/dare/compare/v0.92.0...v0.92.1) (2025-01-23)


### Bug Fixes

* **handler:** enable handlers to attach filters to the request, fixes [#391](https://github.com/5app/dare/issues/391) ([#394](https://github.com/5app/dare/issues/394)) ([d6323b7](https://github.com/5app/dare/commit/d6323b7842cb0a40e6d891b8325fcf334ec961ae))

# [0.92.0](https://github.com/5app/dare/compare/v0.91.0...v0.92.0) (2024-11-04)


Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ await dare.get({
| `models` | `Object<ModelName, Model>` | An object where the keys are the model names to which models can be referred. |
| `validateInput` | `Function(fieldAttributes, field, value)` | Validate input on _patch_ and _post_ operations |
| `getFieldKey` | `Function(field, schema)` | Override the default function for retrieving schema fields, this is useful if you want to support altenative case (camelCase and/or snakeCase) |
| `state` | `any` | Arbitary data which can be used within the Method handlers to set additional filters or formatting |

# Model

Expand Down Expand Up @@ -1022,11 +1023,13 @@ const resp = await dare.get({

## `model.get`

Here's an example of setting a model to be invoked whenever we access `users` model, we'll go into each of the properties afterwards.
Here's an example of setting a model to be invoked whenever we access `users` model. In the below example we're restricting what records the user has access to.

```js
function get(options) {
options.filter.deleted = null;

// In this example we're filtering access to the `users` model by the properties of the `state` data.
options.filter.id = options.state.userId;
}

// For completeness we'll assume the new Dare instance approach for adding the options...
Expand All @@ -1043,9 +1046,12 @@ await dare.get({
table: 'users',
fields: ['name'],
limit: 100,
state: {
userId: 123,
}
});

// SELECT name FROM users WHERE deleted = false LIMIT 100;
// SELECT name FROM users WHERE id = 123 LIMIT 100;
```

# Data validation
Expand Down
Loading
Loading