
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
typed-pocketbase
Advanced tools
Add types to the PocketBase JavaScript SDK.
# npm
npm i typed-pocketbase
# pnpm
pnpm i typed-pocketbase
# yarn
yarn add typed-pocketbase
Generate the PocketBase types using pocketbase-typegen:
npx pocketbase-typegen --db ./pb_data/data.db --out pocketbase-types.ts
Create a PocketBase client and add types:
import PocketBase from 'pocketbase';
import { TypedPocketBase } from 'typed-pocketbase';
import { CollectionRecords } from './pocketbase-types';
const db: TypedPocketBase<CollectionRecords> = new PocketBase('http://localhost:8090');
Enjoy full type-safety:
import { neq, sort, fields } from 'typed-pocketbase';
db.collection('posts').getList(1, 10, {
fields: fields('id', 'title', 'content'),
sort: sort('-date'),
filter: neq('content', '')
});
Supported methods
Use the fields
function to select the properties:
import { fields } from 'typed-pocketbase';
db.collection('posts').getFullList({
fields: fields('id', 'title', 'content')
});
// conditionally select fields
// falsy values are excluded
db.collection('posts').getFullList({
fields: fields(shouldIncludeId && 'id', 'title', 'content')
});
Use the and
, or
and some other utility function to filter rows:
import { and, or, eq } from 'typed-pocketbase';
// get all posts created in 2022
db.collection('posts').getFullList({
filter: and(['date', '<', '2023-01-01'], ['data', '>=', '2022-01-01'])
});
// get all posts expect for those created in 2022
db.collection('posts').getFullList({
filter: or(['date', '>=', '2023-01-01'], ['data', '<', '2022-01-01'])
});
// get all posts that were create at '2023-01-01'
db.collection('posts').getFullList({
filter: eq('date', '2023-01-01')
});
// combine or/and with helpers and manual filters
db.collection('posts').getFullList({
filter: or(
//
['date', '>=', '2023-01-01'],
lt('date', '2022-01-01')
)
});
// conditionally filter rows
// falsy values are excluded
db.collection('posts').getFullList({
filter: and(
//
gte('date', '2022-01-01'),
!untilNow && lt('date', '2023-01-01')
)
});
Most filter operators are available as a short hand.
Visit the pocketbase documentation to find out about all filters in the List/Search records
section.
Use the sort
function to sort the rows:
import { sort, asc, desc } from 'typed-pocketbase';
db.collection('posts').getFullList({
// sort by descending 'date' and ascending 'title'
sort: sort('-date', '+title')
});
db.collection('posts').getFullList({
// sort by descending 'date' and ascending 'title'
sort: sort(desc('date'), asc('title'))
});
// you can mix functions with +/- prefixes
db.collection('posts').getFullList({
// sort by descending 'date' and ascending 'title'
sort: sort(desc('date'), '+title')
});
// conditionally sort rows
// falsy values are excluded
db.collection('posts').getFullList({
sort: sort(
//
desc('date'),
sortTitle && asc('title')
)
});
0.0.2
FAQs
Add types to the PocketBase JavaScript SDK
The npm package typed-pocketbase receives a total of 20 weekly downloads. As such, typed-pocketbase popularity was classified as not popular.
We found that typed-pocketbase demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.