pocketbase
Advanced tools
Changelog
0.20.1
PB_CONNECT
event to allow listening to the realtime connect/reconnect events.
pb.realtime.subscribe("PB_CONNECT", (e) => {
console.log(e.clientId);
})
Changelog
0.20.0
Added expand
, filter
, fields
, custom query and headers parameters support for the realtime subscriptions.
pb.collection("example").subscribe("*", (e) => {
...
}, { filter: "someField > 10" });
This works only with PocketBase v0.20.0+.
Changes to the logs service methods in relation to the logs generalization in PocketBase v0.20.0+:
pb.logs.getRequestsList(...) -> pb.logs.getList(...)
pb.logs.getRequest(...) -> pb.logs.getOne(...)
pb.logs.getRequestsStats(...) -> pb.logs.getStats(...)
Added missing SchemaField.presentable
field.
Added new AuthProviderInfo.displayName
string field.
Added new AuthMethodsList.onlyVerified
bool field.
Changelog
0.19.0
Added pb.filter(rawExpr, params?)
helper to construct a filter string with placeholder parameters populated from an object.
const record = await pb.collection("example").getList(1, 20, {
// the same as: "title ~ 'te\\'st' && (totalA = 123 || totalB = 123)"
filter: pb.filter("title ~ {:title} && (totalA = {:num} || totalB = {:num})", { title: "te'st", num: 123 })
})
The supported placeholder parameter values are:
string
(single quotes will be autoescaped)number
boolean
Date
object (will be stringified into the format expected by PocketBase)null
JSON.stringify()
Changelog
0.18.3
RecordService
(#251).
This should allow specifying a single TypeScript definition for the client, eg. using type assertion:
interface Task {
id: string;
name: string;
}
interface Post {
id: string;
title: string;
active: boolean;
}
interface TypedPocketBase extends PocketBase {
collection(idOrName: string): RecordService // default fallback for any other collection
collection(idOrName: 'tasks'): RecordService<Task>
collection(idOrName: 'posts'): RecordService<Post>
}
...
const pb = new PocketBase("http://127.0.0.1:8090") as TypedPocketBase;
// the same as pb.collection('tasks').getOne<Task>("RECORD_ID")
await pb.collection('tasks').getOne("RECORD_ID") // -> results in Task
// the same as pb.collection('posts').getOne<Post>("RECORD_ID")
await pb.collection('posts').getOne("RECORD_ID") // -> results in Post
Changelog
0.18.1
requestKey
param.Changelog
0.18.0
Added pb.backups.upload(data)
action (available with PocketBase v0.18.0).
Added experimental autoRefreshThreshold
option to auto refresh (or reauthenticate) the AuthStore when authenticated as admin.
This could be used as an alternative to fixed Admin API keys.
await pb.admins.authWithPassword("test@example.com", "1234567890", {
// This will trigger auto refresh or auto reauthentication in case
// the token has expired or is going to expire in the next 30 minutes.
autoRefreshThreshold: 30 * 60
})