Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,39 @@ const users = await admin.resource('adminuser').list(
);
```

## Using a raw SQL in queries.

Rarely you might want to add ciondition for some exotic SQL but still want to keep the rest of API.
Technically it happened that AdminForth allows you to do this also

```js
const minUgcAge = 18;
const usersWithNoUgcAccess = await admin.resource('adminuser').list(
[
Filters.NEQ('role', 'Admin'),
{
insecureRawSQL: `(user_meta->>'age') < ${sqlstring.escape(minUgcAge)}`
}

], 15, 0, Sorts.DESC('createdAt')
);

This will produce next SQL query:
```

```
SELECT *
FROM "adminuser"
WHERE "role" != 'Admin'
AND (user_meta->>'age') < 18
ORDER BY "createdAt" DESC
LIMIT 15 OFFSET 0;

```


Finds users with age less then 18 from meta field which should be a JSONB field in Postgress.

## Create a new item in database

Signature:
Expand Down